Skip to content

Commit

Permalink
TST: consistent result in dropping NA from CSV (pandas-dev#29424)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyoung authored and Mateusz Górski committed Nov 18, 2019
1 parent 7a58da3 commit 30800ee
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 30800ee

Please sign in to comment.