Skip to content

BUG: inferred_freq results in None with eastern hemisphere timezones #7318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/v0.14.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ Bug Fixes
- Bug in ``isnull()`` when ``mode.use_inf_as_null == True`` where isnull
wouldn't test ``True`` when it encountered an ``inf``/``-inf``
(:issue:`7315`).
- Bug in inferred_freq results in None for eastern hemisphere timezones (:issue:`7310`)
3 changes: 3 additions & 0 deletions pandas/tseries/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,9 @@ class _FrequencyInferer(object):
def __init__(self, index, warn=True):
self.index = index
self.values = np.asarray(index).view('i8')
if index.tz is not None:
self.values = tslib.date_normalize(self.values, index.tz)

self.warn = warn

if len(index) < 3:
Expand Down
16 changes: 16 additions & 0 deletions pandas/tseries/tests/test_frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,22 @@ def test_infer_freq(self):
rng = Index(rng.to_timestamp('D', how='e').asobject)
self.assertEqual(rng.inferred_freq, 'Q-OCT')

def test_infer_freq_tz(self):

# GH 7310
for tz in [None, 'Asia/Tokyo', 'US/Pacific', 'Europe/Paris']:
dates = ['2010-11-30', '2010-12-31', '2011-01-31', '2011-02-28']
idx = DatetimeIndex(dates)
self.assertEqual(idx.inferred_freq, 'M')

dates = ['2011-01-01', '2011-01-02', '2011-01-03', '2011-01-04']
idx = DatetimeIndex(dates)
self.assertEqual(idx.inferred_freq, 'D')

dates = ['2011-12-31 22:00', '2011-12-31 23:00', '2012-01-01 00:00', '2012-01-01 01:00']
idx = DatetimeIndex(dates)
self.assertEqual(idx.inferred_freq, 'H')

def test_not_monotonic(self):
rng = _dti(['1/31/2000', '1/31/2001', '1/31/2002'])
rng = rng[::-1]
Expand Down