allowing datetime and timedelta datatype in pd cut bins by aileronajay · Pull Request #14798 · pandas-dev/pandas (original) (raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually you prob want to test with datetime.datetime, Timestamp, np.datetime64 (but just put them in a loop something like

data = ['2012-12-12', '2012-12-14']

for conv in [Timestamp(x).to_pydatetime, Timestamp, np.datetime64]:
      bins = [ conv(v) for v in data ]

also test
bins = pd.to_datetime(data)

these should all work, because internally you need to wrap a Timestamp converter around each of fhe bins (if dtype==M8) or Timedelta if dtype==m8