【问题标题】:encounter error 'str' object has no attribute 'log' when perform np.log()执行 np.log() 时遇到错误“str”对象没有属性“log”
【发布时间】:2020-04-01 02:34:14
【问题描述】:

在我将日期设置为日期对象并使其成为索引后,当我使用 np.log() 时,我收到了错误消息: AttributeError:'str' 对象没有属性'log' TypeError: ufunc 循环不支持 str 类型的参数 0,它没有可调用的日志方法 我的输入值是一系列数据,应该没问题 python codes

【问题讨论】:

  • 你有一个带有字符串的对象 dtype 数组(可能还有其他东西)
  • 请提供MVCE
  • 你为什么要使用log 和日期?

标签: python numpy attributeerror logarithm


【解决方案1】:

您是否尝试过在应用日志之前获取这些值并将它们放入一个数组中?

np.log(np.array(ts_data.values))

【讨论】:

    猜你喜欢
    • 2016-04-07
    • 1970-01-01
    • 2021-07-19
    • 1970-01-01
    • 2018-02-08
    • 2018-03-15
    • 2019-03-30
    • 2016-01-29
    • 1970-01-01
    相关资源
    最近更新 更多