Skip to content

set_index does not set 'freq' #11314

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

Closed
joshplumley opened this issue Oct 13, 2015 · 1 comment
Closed

set_index does not set 'freq' #11314

joshplumley opened this issue Oct 13, 2015 · 1 comment
Labels
Datetime Datetime data dtype
Milestone

Comments

@joshplumley
Copy link

pandas 0.17.0 does not seem to set the freq attribute on the index anymore. I believe 0.16.2 did.

Example:

import pandas
import numpy
import datetime

df = pandas.DataFrame(numpy.random.randn(24, 1), columns=['a'], index=pandas.date_range(datetime.datetime(2015, 10, 1), datetime.datetime(2015,10,1,23), freq='H', tz='US/Eastern'))
new_index = pandas.date_range(datetime.datetime(2015, 10, 2), datetime.datetime(2015,10,2,23), freq='H', tz='US/Eastern')
new_df = df.set_index(new_index)

In [2]: df.index
Out[2]: 
DatetimeIndex(['2015-10-01 00:00:00-04:00', '2015-10-01 01:00:00-04:00',
               '2015-10-01 02:00:00-04:00', '2015-10-01 03:00:00-04:00',
               '2015-10-01 04:00:00-04:00', '2015-10-01 05:00:00-04:00',
               '2015-10-01 06:00:00-04:00', '2015-10-01 07:00:00-04:00',
               '2015-10-01 08:00:00-04:00', '2015-10-01 09:00:00-04:00',
               '2015-10-01 10:00:00-04:00', '2015-10-01 11:00:00-04:00',
               '2015-10-01 12:00:00-04:00', '2015-10-01 13:00:00-04:00',
               '2015-10-01 14:00:00-04:00', '2015-10-01 15:00:00-04:00',
               '2015-10-01 16:00:00-04:00', '2015-10-01 17:00:00-04:00',
               '2015-10-01 18:00:00-04:00', '2015-10-01 19:00:00-04:00',
               '2015-10-01 20:00:00-04:00', '2015-10-01 21:00:00-04:00',
               '2015-10-01 22:00:00-04:00', '2015-10-01 23:00:00-04:00'],
              dtype='datetime64[ns, US/Eastern]', freq='H')

In [3]: new_df.index
Out[3]: 
DatetimeIndex(['2015-10-02 00:00:00-04:00', '2015-10-02 01:00:00-04:00',
               '2015-10-02 02:00:00-04:00', '2015-10-02 03:00:00-04:00',
               '2015-10-02 04:00:00-04:00', '2015-10-02 05:00:00-04:00',
               '2015-10-02 06:00:00-04:00', '2015-10-02 07:00:00-04:00',
               '2015-10-02 08:00:00-04:00', '2015-10-02 09:00:00-04:00',
               '2015-10-02 10:00:00-04:00', '2015-10-02 11:00:00-04:00',
               '2015-10-02 12:00:00-04:00', '2015-10-02 13:00:00-04:00',
               '2015-10-02 14:00:00-04:00', '2015-10-02 15:00:00-04:00',
               '2015-10-02 16:00:00-04:00', '2015-10-02 17:00:00-04:00',
               '2015-10-02 18:00:00-04:00', '2015-10-02 19:00:00-04:00',
               '2015-10-02 20:00:00-04:00', '2015-10-02 21:00:00-04:00',
               '2015-10-02 22:00:00-04:00', '2015-10-02 23:00:00-04:00'],
              dtype='datetime64[ns, US/Eastern]', freq=None)

The datetime appears to have been set correctly, but the freq is = None on the new_df. Is this normal behavior with pandas 0.17.0?

@jreback
Copy link
Contributor

jreback commented Oct 13, 2015

this was fixed here: #11301, and will be in 0.17.1 (was an unrelated bug-report)

@jreback jreback closed this as completed Oct 13, 2015
@jreback jreback added this to the 0.17.1 milestone Oct 13, 2015
@jreback jreback added the Datetime Datetime data dtype label Oct 13, 2015
jreback added a commit to jreback/pandas that referenced this issue Oct 13, 2015
jreback added a commit that referenced this issue Oct 13, 2015
TST: validation tests for #11314, set_index with a tz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype
Projects
None yet
Development

No branches or pull requests

2 participants