Skip to content

Commit 706b8df

Browse files
committed
add issue number, construct correct frame and compare with assert_frame_equal
1 parent 1549094 commit 706b8df

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

pandas/io/tests/test_date_converters.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import numpy as np
1212
from numpy.testing.decorators import slow
1313

14-
from pandas import DataFrame, Series, Index, isnull
14+
from pandas import DataFrame, Series, Index, MultiIndex, isnull
1515
import pandas.io.parsers as parsers
1616
from pandas.io.parsers import (read_csv, read_table, read_fwf,
1717
TextParser)
@@ -120,22 +120,30 @@ def test_generic(self):
120120
self.assertEqual(df.ym.ix[0], date(2001, 1, 1))
121121

122122
def test_dateparser_resolution_if_not_ns(self):
123+
# issue 10245
123124
data = """\
124-
week,sow,prn,rxstatus
125-
2013-11-03,19:00:00,126,00E80000
126-
2013-11-03,19:00:00,23,00E80000
127-
2013-11-03,19:00:00,13,00E80000
125+
date,time,prn,rxstatus
126+
2013-11-03,19:00:00,126,00E80000
127+
2013-11-03,19:00:00,23,00E80000
128+
2013-11-03,19:00:00,13,00E80000
128129
"""
129130

130131
def date_parser(date, time):
131132
datetime = np.array(date + 'T' + time + 'Z', dtype='datetime64[s]')
132133
return datetime
133134

134135
df = read_csv(StringIO(data), date_parser=date_parser,
135-
parse_dates={'datetime': ['week', 'sow']},
136+
parse_dates={'datetime': ['date', 'time']},
136137
index_col=['datetime', 'prn'])
137138

138-
self.assertEqual(df.index[0][0], datetime(2013, 11, 3, 19))
139+
datetimes = np.array(['2013-11-03T19:00:00Z']*3, dtype='datetime64[s]')
140+
df_correct = DataFrame(data={'rxstatus': ['00E80000']*3},
141+
index=MultiIndex.from_tuples(
142+
[(datetimes[0], 126),
143+
(datetimes[1], 23),
144+
(datetimes[2], 13)],
145+
names=['datetime', 'prn']))
146+
assert_frame_equal(df, df_correct)
139147

140148
if __name__ == '__main__':
141149
import nose

0 commit comments

Comments
 (0)