Skip to content

set_index does not set 'freq'  #11314

Closed
Closed
@joshplumley

Description

@joshplumley

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions