Skip to content

Commit 91ab7be

Browse files
committed
Add another test for whitespace skipping
1 parent 1ef7d82 commit 91ab7be

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

+17
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,23 @@ def decimal_number_check(parser, numeric_decimal, thousands, float_precision):
226226
val = df.iloc[0, 0]
227227
assert val == numeric_decimal[1]
228228

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

230247
def test_true_values_cast_to_bool(all_parsers):
231248
# GH#34655

0 commit comments

Comments
 (0)