【问题标题】:Pyarrow error - AttributeError: module 'pyarrow' has no attribute 'feather'Pyarrow 错误 - AttributeError:模块 'pyarrow' 没有属性 'feather'
【发布时间】:2020-09-13 20:47:31
【问题描述】:

我使用conda install pyarrow 在通过 Anaconda 导航器启动的 Spyder 中安装 pyarrow。但是在尝试以羽毛格式保存文件后,我收到了以下错误。

回溯(最近一次通话最后一次): 文件“”,第 1 行,在 pyarrow.feather.write_feather(df,"/Users/omg/Downloads/testFeather.ftr") AttributeError: 模块 'pyarrow' 没有属性 'feather'

代码是

import pandas as pd
import pyarrow

tempArr = np.reshape(np.zeros(10), (5,2))
tempArr += 1
df = pd.DataFrame(tempArr, columns=['a', 'b'])
pyarrow.feather.write_feather(df,"/Users/omg/Downloads/testFeather.ftr")

版本是: pyarrow.版本 '0.11.1' np.版本 '1.18.1'

pd.版本 '1.0.3'

【问题讨论】:

  • 您的pyarrow 版本太旧了,尝试更新到0.17(或至少0.15+)
  • 一件事是conda,即使使用forge,也只能找到0.11以下的版本。我强制安装0.15。也许 conda 也应该解决这个问题。
  • conda-forge 有最近的 pyarrow=0.17.1,如果你的环境中没有安装它,你可能有另一个引用 pyarrow=0.11 的过时包。

标签: python pandas numpy pyarrow feather


【解决方案1】:

featherpyarrow 中的一个模块。这应该有效:

import pandas as pd
from pyarrow import feather
import numpy as np

tempArr = np.reshape(np.zeros(10), (5,2))
tempArr += 1
df = pd.DataFrame(tempArr, columns=['a', 'b'])
feather.write_feather(df,"testFeather.ftr")

【讨论】:

    猜你喜欢
    • 2019-07-25
    • 1970-01-01
    • 2021-10-22
    • 1970-01-01
    • 1970-01-01
    • 2020-03-08
    • 2019-02-18
    • 2019-12-10
    • 2022-01-20
    相关资源
    最近更新 更多