Skip to content

Commit 0ca946c

Browse files
committed
pandas-dev issue #36111
1 parent 3eef307 commit 0ca946c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pandas/tests/io/parser/test_parse_dates.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ def test_separator_date_conflict(all_parsers):
5555
)
5656
tm.assert_frame_equal(df, expected)
5757

58-
@pytest.fixtures(all_parsers)
59-
def test_read_csv_with_custom_date_parser(self, all_parsers):
58+
def test_read_csv_with_custom_date_parser(self):
6059
# GH36111
61-
60+
def __custom_date_parser(time):
61+
time = time.astype(np.float)
62+
time = time.astype(np.int) # convert float seconds to int type
63+
return pd.to_timedelta(time, unit='s')
6264
testdata = StringIO(
6365
"""time e n h
6466
41047.00 -98573.7297 871458.0640 389.0089
@@ -73,7 +75,7 @@ def test_read_csv_with_custom_date_parser(self, all_parsers):
7375
testdata,
7476
delim_whitespace=True,
7577
parse_dates=True,
76-
date_parser=all_parsers,
78+
date_parser=__custom_date_parser,
7779
index_col="time",
7880
)
7981
expected = pd.DataFrame(
@@ -82,8 +84,9 @@ def test_read_csv_with_custom_date_parser(self, all_parsers):
8284
"n": [871458.0640, 871458.0640, 871458.0642, 871458.0643, 871458.0640],
8385
"h": [389.0089, 389.0089, 389.0088, 389.0088, 389.0086],
8486
},
85-
index=[41047.00, 41048.00, 41049.00, 41050.00, 41051.00],
87+
index=[41047, 41048, 41049, 41050, 41051],
8688
)
89+
expected = expected.astype(np.int)
8790
tm.assert_frame_equal(result, expected)
8891

8992

0 commit comments

Comments
 (0)