You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I didn't directly find something about this, but is there a reason why the Period(Index) constructor does not take datetime64 values? As it does accept datetime:
In [15]: t = pd.Timestamp('2012-01-01')
In [16]: t.to_pydatetime()
Out[16]: datetime.datetime(2012, 1, 1, 0, 0)
In [17]: t.asm8
Out[17]: numpy.datetime64('2012-01-01T01:00:00.000000000+0100')
In [19]: pd.Period(t, freq='D')
Out[19]: Period('2012-01-01', 'D')
In [20]: pd.Period(t.to_pydatetime(), freq='D')
Out[20]: Period('2012-01-01', 'D')
In [21]: pd.Period(t.asm8, freq='D')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-21-f08079765cf6> in <module>()
----> 1 pd.Period(t.asm8, freq='D')
C:\Anaconda\lib\site-packages\pandas\tseries\period.pyc in __init__(self, value,
freq, ordinal, year, month, quarter, day, hour, minute, second)
141 else:
142 msg = "Value must be Period, string, integer, or datetime"
--> 143 raise ValueError(msg)
144
145 base, mult = _gfc(freq)
ValueError: Value must be Period, string, integer, or datetime
The text was updated successfully, but these errors were encountered:
I didn't directly find something about this, but is there a reason why the
Period(Index)
constructor does not take datetime64 values? As it does acceptdatetime
:The text was updated successfully, but these errors were encountered: