两个显示错误的datetime64 [ns]列之间的差异 [英] Difference between two datetime64[ns] column showing error

查看:1154
本文介绍了两个显示错误的datetime64 [ns]列之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如图所示,我有两个类型为datetime64 [ns]的数据框列.我需要找到它们之间的区别.当我尝试这样做时,出现错误.如果我试图找出同一数据帧中每一列的一个元素之间的差异,那会给我时间增量.是否可能缺少我的东西?

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?

  • 我已经包括了日期时间
  • 这些列是使用pd.to_datetime()从int64类型的列转换的

--------------------------------------------------- ---------------------------- TypeError跟踪(最近的呼叫 最后)在() ----> 1 c =数据['created_at']-数据['launched_at']

--------------------------------------------------------------------------- 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 在包装器中(左,右,名称,na_op) 694 left,right = _align_method_SERIES(左,右) 695 -> 696转换= _Op.get_op(左,右,名称,na_op) 697 698 left,right = converted.left,conversion.right

/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 在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 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 在 init (自己,左,右,姓名,na_op)中 341 super(_TimeOp,self). init (左,右,名称,na_op) 342 -> 343个左值= 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 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 在_convert_to_array中(自己,值,名称,其他) 第452章 453 inferred_type =提供的dtype或lib.infer_dtype(值) -> 454 if(inferred_type in('datetime64','datetime','date','time')或 第455章 456#如果我们还有另一个timedelta,但是在这里使用pd.NaT我们

/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:数据类型"datetime"无法理解

TypeError: data type "datetime" not understood

作为int64数据类型:

As int64 datatype:

转换为日期时间格式后

推荐答案

好吧,我通过将熊猫更新到v0.20.2来解决了这个问题.实际上,当我使用Anaconda时,我做了一个conda update pandas,它也更新了依赖于熊猫的事物(也就是说,一切).

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).

这篇关于两个显示错误的datetime64 [ns]列之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆