【问题标题】:Python - FamaMacBeth, cannot astype a datetimelike from [datetime64[ns]] to [float64]Python - FamaMacBeth,不能从 [datetime64[ns]] 到 [float64] 键入 datetimelike
【发布时间】:2018-11-22 22:40:22
【问题描述】:

尝试在我的数据集上运行FamaMacBeth 回归时,我得到TypeError

cannot astype a datetimelike from [datetime64[ns]] to [float64],

我的日期列的类型是numpy.ndarray

有人知道我做错了什么吗?

【问题讨论】:

    标签: python python-3.x time-series regression


    【解决方案1】:

    这是known issue

    问题是我们不支持 pandas 对象的 datetime64[s] 类型,即使它是 NumPy 数组的有效类型。

    一种可能的解决方法是直接转换为浮点数,如对此问题的评论:

    Pandas DataFrame - 'cannot astype a datetimelike from [datetime64[ns]] to [float64]' when using ols/linear regression

    【讨论】:

      猜你喜欢
      • 2019-10-11
      • 1970-01-01
      • 2017-03-20
      • 1970-01-01
      • 2017-01-05
      • 1970-01-01
      • 2019-12-12
      • 2023-04-05
      • 2019-04-29
      相关资源
      最近更新 更多