1

I have two timeseries that I got from a feather file. One series turned into dtype datetime64[ns] the other turned into datetime64[ns, UTC] as the formats are different I can't run pd.merge how can I fix this? pd.to_datetime(column, utc=False) doesn't seem to do it?

cel
  • 30,017
  • 18
  • 97
  • 117
KillerSnail
  • 3,321
  • 11
  • 46
  • 64

1 Answers1

4

I'm still looking for other answers...
However, this works:
Consider the time series ts

ts = pd.date_range('2016-03-31', periods=6, freq='4H', tz='Asia/Hong_Kong')
ts

DatetimeIndex(['2016-03-31 00:00:00+08:00', '2016-03-31 04:00:00+08:00',
               '2016-03-31 08:00:00+08:00', '2016-03-31 12:00:00+08:00',
               '2016-03-31 16:00:00+08:00', '2016-03-31 20:00:00+08:00'],
              dtype='datetime64[ns, Asia/Hong_Kong]', freq='4H')

Then strip off timezone information by building from values

pd.to_datetime(ts.values)

DatetimeIndex(['2016-03-30 16:00:00', '2016-03-30 20:00:00',
               '2016-03-31 00:00:00', '2016-03-31 04:00:00',
               '2016-03-31 08:00:00', '2016-03-31 12:00:00'],
              dtype='datetime64[ns]', freq=None)
piRSquared
  • 285,575
  • 57
  • 475
  • 624