Skip to content

ENH: Add Index.normalize as a Series or DataFrame method #5502

Closed
@cancan101

Description

@cancan101

Currently normalize does not work on a Series or a DataFrame:

pd.Series(range(5), index=pd.date_range('2013-1-1', periods=5,freq='D')).normalize()
AttributeError: 'Series' object has no attribute 'normalize'

However, changing the timezone, which I consider to be a similar type of operation, does work:

In [50]: pd.Series(range(5), index=pd.date_range('2013-1-1', periods=5,freq='D')).tz_localize('America/New_York')
Out[50]: 
2013-01-01 00:00:00-05:00    0
2013-01-02 00:00:00-05:00    1
2013-01-03 00:00:00-05:00    2
2013-01-04 00:00:00-05:00    3
2013-01-05 00:00:00-05:00    4
Freq: D, dtype: int64

My current workaround:

s = pd.Series(range(5), index=pd.date_range('2013-1-1', periods=5,freq='D'))
s.index = s.index.normalize()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions