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
In [1]: s = pd.Series(pd.date_range('20180101', periods=3))
In [2]: s
Out[2]:
0 2018-01-01
1 2018-01-02
2 2018-01-03
dtype: datetime64[ns]
In [3]: res, bins = pd.cut(s, 2, retbins=True)
In [4]: pd.cut(s, bins) # Bins do not "roundtrip"
ValueError: bins must be of datetime64 dtype
In [5]: pd.cut(s, [pd.Timestamp(b) for b in bins]) == res
Out[5]:
0 True
1 True
2 True
dtype: bool
For convenience and argument of "roundtripping", I think cut(..., retbins=True) with datelike data (datetime or timedelta data) should return bins that is an array of Timestamp/Timedelta objects instead of an array of integers.
The text was updated successfully, but these errors were encountered:
For convenience and argument of "roundtripping", I think
cut(..., retbins=True)
with datelike data (datetime or timedelta data) should return bins that is an array ofTimestamp
/Timedelta
objects instead of an array of integers.The text was updated successfully, but these errors were encountered: