Skip to content

Commit 87186c9

Browse files
committed
TST: consistent result in dropping NA from CSV
Closes pandas-dev#21131
1 parent d569905 commit 87186c9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pandas/tests/io/parser/test_na_values.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,3 +536,28 @@ def test_cast_NA_to_bool_raises_error(all_parsers, data, na_values):
536536
dtype={"a": "bool"},
537537
na_values=na_values,
538538
)
539+
540+
541+
def test_str_nan_dropped(all_parsers):
542+
# see gh-21131
543+
parser = all_parsers
544+
545+
data = """File: small.csv,,
546+
10010010233,0123,654
547+
foo,,bar
548+
01001000155,4530,898"""
549+
550+
result = parser.read_csv(
551+
StringIO(data),
552+
header=None,
553+
names=["col1", "col2", "col3"],
554+
dtype={"col1": str, "col2": str, "col3": str},
555+
).dropna()
556+
557+
expected = DataFrame({
558+
"col1": ["10010010233", "01001000155"],
559+
"col2": ["0123", "4530"],
560+
"col3": ["654", "898"]
561+
}, index=[1, 3])
562+
563+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)