Skip to content

BUG: Series.dt ops reset name #10712

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
sinhrks opened this issue Jul 31, 2015 · 0 comments
Closed

BUG: Series.dt ops reset name #10712

sinhrks opened this issue Jul 31, 2015 · 0 comments
Labels
Bug Datetime Datetime data dtype
Milestone

Comments

@sinhrks
Copy link
Member

sinhrks commented Jul 31, 2015

DatetimeIndex.tz_localize preserves name.

import pandas as pd
idx = pd.date_range('2011-01-01', periods=5, freq='M', name='x')
idx
# DatetimeIndex(['2011-01-31', '2011-02-28', '2011-03-31', '2011-04-30', '2011-05-31'],
#               dtype='datetime64[ns]', name=u'x', freq='M', tz=None)
idx.tz_localize('US/Eastern')
# DatetimeIndex(['2011-01-31 00:00:00-05:00', '2011-02-28 00:00:00-05:00',
#                '2011-03-31 00:00:00-04:00', '2011-04-30 00:00:00-04:00',
#                '2011-05-31 00:00:00-04:00'],
#               dtype='datetime64[ns]', name=u'x', freq='M', tz='US/Eastern')

But Series doesn't. I don't check all methods which can return Series yet.

s = pd.Series(idx)
s
#0   2011-01-31
#1   2011-02-28
#2   2011-03-31
#3   2011-04-30
#4   2011-05-31
# Name: x, dtype: datetime64[ns]

# NG, name is reset
s2 = s.dt.tz_localize('US/Eastern')
s2
#0    2011-01-31 00:00:00-05:00
#1    2011-02-28 00:00:00-05:00
#2    2011-03-31 00:00:00-04:00
#3    2011-04-30 00:00:00-04:00
#4    2011-05-31 00:00:00-04:00
# dtype: object

# NG, name is reset
s2.name = 'x'
s2.dt.tz_convert('US/Pacific')
#0    2011-01-30 21:00:00-08:00
#1    2011-02-27 21:00:00-08:00
#2    2011-03-30 21:00:00-07:00
#3    2011-04-29 21:00:00-07:00
#4    2011-05-30 21:00:00-07:00
# dtype: object

# NG, name is reset
s.dt.normalize()
#0   2011-01-31
#1   2011-02-28
#2   2011-03-31
#3   2011-04-30
#4   2011-05-31
# dtype: datetime64[ns]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants