Skip to content

Commit 32305bc

Browse files
committed
Add another test for whitespace skipping
1 parent 1ef7d82 commit 32305bc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/io/parser/dtypes/test_dtypes_basic.py

+18
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,24 @@ def decimal_number_check(parser, numeric_decimal, thousands, float_precision):
227227
assert val == numeric_decimal[1]
228228

229229

230+
@pytest.mark.parametrize("float_precision", [None, "legacy", "high", "round_trip"])
231+
def test_skip_whitespace(c_parser_only, float_precision):
232+
DATA = (
233+
"id\tnum\n"
234+
"1\t1.2 \n"
235+
"1\t 2.1\n"
236+
"2\t 1\n"
237+
"2\t 1.2 \n"
238+
)
239+
df = c_parser_only.read_csv(
240+
StringIO(DATA),
241+
float_precision=float_precision,
242+
sep="\t", header=0,
243+
dtype={1: np.float64},
244+
)
245+
tm.assert_series_equal(df.iloc[:, 1], pd.Series([1.2, 2.1, 1., 1.2], name="num"))
246+
247+
230248
def test_true_values_cast_to_bool(all_parsers):
231249
# GH#34655
232250
text = """a,b

0 commit comments

Comments
 (0)