0

As show in figure I have two dataframe columns of type datetime64[ns]. I need to find difference between them. When I try to do so, I am getting error. If I try to find difference between one element of each column in same data frame, it is giving me time delta.Is there something that I may be missing?

enter image description here

  • I have included date time
  • These columns are converted from int64 type column using pd.to_datetime()

--------------------------------------------------------------------------- TypeError Traceback (most recent call last) in () ----> 1 c = data['created_at'] - data['launched_at']

/home/adi/.virtualenvs/datascience/local/lib/python2.7/site-packages/pandas/core/ops.pyc in wrapper(left, right, name, na_op) 694 left, right = _align_method_SERIES(left, right) 695 --> 696 converted = _Op.get_op(left, right, name, na_op) 697 698 left, right = converted.left, converted.right

/home/adi/.virtualenvs/datascience/local/lib/python2.7/site-packages/pandas/core/ops.pyc in get_op(cls, left, right, name, na_op) 328 return _Op(left, right, name, na_op) 329 else: --> 330 return _TimeOp(left, right, name, na_op) 331 332

/home/adi/.virtualenvs/datascience/local/lib/python2.7/site-packages/pandas/core/ops.pyc in init(self, left, right, name, na_op) 341 super(_TimeOp, self).init(left, right, name, na_op) 342 --> 343 lvalues = self._convert_to_array(left, name=name) 344 rvalues = self._convert_to_array(right, name=name, other=lvalues) 345

/home/adi/.virtualenvs/datascience/local/lib/python2.7/site-packages/pandas/core/ops.pyc in _convert_to_array(self, values, name, other) 452 supplied_dtype = values.dtype 453 inferred_type = supplied_dtype or lib.infer_dtype(values) --> 454 if (inferred_type in ('datetime64', 'datetime', 'date', 'time') or 455 is_datetimetz(inferred_type)): 456 # if we have a other of timedelta, but use pd.NaT here we

TypeError: data type "datetime" not understood

As int64 datatype:

enter image description here

After conversion to datetime format

enter image description here

Adarsh Nair
  • 370
  • 2
  • 4
  • 17

1 Answers1

0

Ok I managed to solve it by doing an update of pandas to v0.20.2. Actually as I'm using Anaconda I did a conda update pandas which update things that depends on pandas too (which is to say everything).

Reddspark
  • 6,934
  • 9
  • 47
  • 64