Skip to content

Commit 1d7521b

Browse files
nbonnottejreback
authored andcommitted
TST asfreq / resample set freq correctly with regular timeseries
1 parent 94b3c48 commit 1d7521b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tseries/tests/test_timeseries.py

+17
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,23 @@ def test_asfreq_keep_index_name(self):
12241224
tm.assert_equal(index_name, df.index.name)
12251225
tm.assert_equal(index_name, df.asfreq('10D').index.name)
12261226

1227+
def test_asfreq_resample_set_correct_freq(self):
1228+
# GH5613
1229+
# we test if .asfreq() and .resample() set the correct value for .freq
1230+
df = pd.DataFrame({'date': ["2012-01-01", "2012-01-02", "2012-01-03"],
1231+
'col': [1, 2, 3]})
1232+
df = df.set_index(pd.to_datetime(df.date))
1233+
1234+
# testing the settings before calling .asfreq() and .resample()
1235+
self.assertEqual(df.index.freq, None)
1236+
self.assertEqual(df.index.inferred_freq, 'D')
1237+
1238+
# does .asfreq() set .freq correctly?
1239+
self.assertEqual(df.asfreq('D').index.freq, 'D')
1240+
1241+
# does .resample() set .freq correctly?
1242+
self.assertEqual(df.resample('D').index.freq, 'D')
1243+
12271244
def test_promote_datetime_date(self):
12281245
rng = date_range('1/1/2000', periods=20)
12291246
ts = Series(np.random.randn(20), index=rng)

0 commit comments

Comments
 (0)