4

I am processing a csv in python (3.5) that has a date field in it. The date contains a microsecond precision of 7 rather than 6, which I believe is the max that strptime can handle.

Without stripping the field the last character, is there a way to make this a datetime object?

Here is the specific code:

d = '2015-07-03 17:29:34.5940379'
pd.datetime.strptime(d, '%Y-%m-%d %H:%M:%S.%f')
ValueError: unconverted data remains: 9
mikebmassey
  • 8,354
  • 26
  • 70
  • 95

1 Answers1

3

If that's the format your numbers are in, just use pd.to_timestamp(d)

datetime.datetime objects only have microsecond resolution (6 digits), but Pandas Timestamps are Numpy datetime64 objects.

cco
  • 5,873
  • 1
  • 16
  • 21