Skip to content

BUG: round-trip datetime-period-datetime not preserving NaT #7228

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
jreback opened this issue May 24, 2014 · 0 comments · Fixed by #7485
Closed

BUG: round-trip datetime-period-datetime not preserving NaT #7228

jreback opened this issue May 24, 2014 · 0 comments · Fixed by #7485
Labels
Bug Datetime Datetime data dtype Period Period data type
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented May 24, 2014

In [76]: data
Out[76]: 
0   2014-10-01
1   2014-10-01
2   2014-10-31
3   2014-11-15
4   2014-11-30
5          NaT
6   2014-12-01
dtype: datetime64[ns]
In [78]: DatetimeIndex(data).to_period(freq='M')
Out[78]: 
<class 'pandas.tseries.period.PeriodIndex'>
freq: M
[2014-10, ..., 2014-12]
length: 7

In [79]: DatetimeIndex(data).to_period(freq='M').values
Out[79]: array([ 537,  537,  537,  538,  538, 3507,  539])

In [80]: DatetimeIndex(data).to_period(freq='M').to_timestamp()
Out[80]: 
<class 'pandas.tseries.index.DatetimeIndex'>
[2014-10-01, ..., 2014-12-01]
Length: 7, Freq: None, Timezone: None

In [81]: DatetimeIndex(data).to_period(freq='M').to_timestamp().values
Out[81]: 
array(['2014-09-30T20:00:00.000000000-0400',
       '2014-09-30T20:00:00.000000000-0400',
       '2014-09-30T20:00:00.000000000-0400',
       '2014-10-31T20:00:00.000000000-0400',
       '2014-10-31T20:00:00.000000000-0400',
       '2262-03-31T20:00:00.000000000-0400',
       '2014-11-30T19:00:00.000000000-0500'], 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 Period Period data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant