dtype('< M8 [ns]')错误 [英] dtype('<M8[ns]') Error

查看:153
本文介绍了dtype('< M8 [ns]')错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是python的新手,今天我正尝试在Financial DataFrame(YYYY-MM-DD的第一列,第二个值)中进行一些操作。
当我尝试应用简单的pct_change()操作时,它给了我这个错误:

I'm kind of new to python, today I was trying to do some operations in a financial DataFrame (first column of YYYY-MM-DD and second one of values). When I tried to apply a simple pct_change() operation, it gave me this error:

TypeError: ufunc true_divide cannot use operands with types 
dtype('<M8[ns]') and dtype('<M8[ns]')

此错误究竟是由什么引起的?我该如何解决呢?因为我在网上找不到很多解释。
提前谢谢!

What is this error exactly caused by? And how can I work around it? Because I couldn't really find many explanations online. Thanks a lot in advance!

推荐答案

dtype('< M8 [ns] ') numpy datetime64 dtypes之一。因此,看来您正在尝试在日期列上进行百分比变化计算,这毫无疑问是行不通的。

dtype('<M8[ns]') is one of the numpy datetime64 dtypes. So it looks like you are trying do your precentage change calculation on the date column which unsuprisingly doesn't work.

解决方案是选择值列。 (由于您未提供必要的详细信息,因此我无法提供更具体的信息。)

The solution would be to select the value column. (I can't be more specific since you are not providing the necessary details.)

这篇关于dtype('&lt; M8 [ns]')错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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