Skip to content

Commit

Permalink
TST: consistent result in dropping NA from CSV
Browse files Browse the repository at this point in the history
Closes #21131
  • Loading branch information
gfyoung committed Nov 5, 2019
1 parent d569905 commit 68e870c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pandas/tests/io/parser/test_na_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,31 @@ def test_cast_NA_to_bool_raises_error(all_parsers, data, na_values):
dtype={"a": "bool"},
na_values=na_values,
)


def test_str_nan_dropped(all_parsers):
# see gh-21131
parser = all_parsers

data = """File: small.csv,,
10010010233,0123,654
foo,,bar
01001000155,4530,898"""

result = parser.read_csv(
StringIO(data),
header=None,
names=["col1", "col2", "col3"],
dtype={"col1": str, "col2": str, "col3": str},
).dropna()

expected = DataFrame(
{
"col1": ["10010010233", "01001000155"],
"col2": ["0123", "4530"],
"col3": ["654", "898"],
},
index=[1, 3],
)

tm.assert_frame_equal(result, expected)

0 comments on commit 68e870c

Please sign in to comment.