Difference between two datetime64 [ns] columns showing error

As shown in the picture, I have two dataframe columns of type datetime64 [ns]. I need to find the difference between them. When I try to do this, I get an error. If I try to find the difference between one element of each column in the same dataframe it gives me the delta time. Is there something I might be missing?

enter image description here

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

----------------------------------------------- --- ------------------------- TypeError Traceback (last call last) in () ----> 1 c = data ['created_at'] - data ['launch_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 convert = _Op.get_op (left, right, name, na_op) +697 698 left, right = convert.left, convert.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: β†’ 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 another timedelta but use pd .NaT here we

TypeError: data type "datetime" did not understand

As int64 data type:

enter image description here

After conversion to date and time format

enter image description here

-1


source to share


1 answer


Well I managed to fix this issue by doing pandas update to v0.20.2. In fact, when I use Anaconda, I did conda update pandas

that also updates everything that depends on pandas (i.e. everything).



0


source







All Articles