Skip to content

Commit 850bd6b

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

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pandas/tests/io/parser/test_na_values.py

+28
Original file line numberDiff line numberDiff line change
@@ -536,3 +536,31 @@ 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+
{
559+
"col1": ["10010010233", "01001000155"],
560+
"col2": ["0123", "4530"],
561+
"col3": ["654", "898"],
562+
},
563+
index=[1, 3],
564+
)
565+
566+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)