两者都是用于数据分析系统的柱状(磁盘)存储格式.两者都集成在Apache Arrow(用于python的pyarrow包)中,旨在与Arrow对应作为柱状内存分析层.
两种格式有何不同?
在可能的情况下,你是否总是喜欢使用羽毛?
附录
我在这里找到了一些提示https://github.com/wesm/feather/issues/188,但考虑到这个项目的年龄,它可能有点过时了.
不是一个严肃的速度测试,因为我只是倾倒并加载一个完整的Dataframe,但如果您之前从未听说过这些格式,那么会给您一些印象:
# IPython
import numpy as np
import pandas as pd
import pyarrow as pa
import pyarrow.feather as feather
import pyarrow.parquet as pq
import fastparquet as fp
df = pd.DataFrame({'one': [-1, np.nan, 2.5],
'two': ['foo', 'bar', 'baz'],
'three': [True, False, True]})
print("pandas df to disk ####################################################")
print('example_feather:')
%timeit feather.write_feather(df, 'example_feather')
# 2.62 ms ± 35.8 µs per loop …Run Code Online (Sandbox Code Playgroud) 我将它保存为羽毛格式,希望我可以在 R 中阅读它。
但是R总是抛出错误“openFeather(path)中的错误:无效:不是羽毛文件回溯:
有人可以在这里帮助我吗?我使用的R代码如下:
library(feather)
dfwin = read_feather('./aFolder/dfwin.feather')```
Run Code Online (Sandbox Code Playgroud) 我尝试将数据帧保存为羽毛格式,但在加载时我得到了错误
os.makedirs('tmp', exist_ok=True)
df_hist.to_feather('tmp/historical-raw')
Run Code Online (Sandbox Code Playgroud)
这是加载回数据集
df_hist= pd.read_feather('tmp/historical-raw')
Run Code Online (Sandbox Code Playgroud)
这给出了以下错误
read_feather() got an unexpected keyword argument 'nthreads'
Run Code Online (Sandbox Code Playgroud)
提前致谢
我有一个大的Pandas数据框(〜15GB,8300万行),我有兴趣另存为h5(或feather)文件。一列包含数字的长ID字符串,该字符串应具有字符串/对象类型。但是即使我确保熊猫将所有列解析为object:
df = pd.read_csv('data.csv', dtype=object)
print(df.dtypes) # sanity check
df.to_hdf('df.h5', 'df')
> client_id object
event_id object
account_id object
session_id object
event_timestamp object
# etc...
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
File "foo.py", line 14, in <module>
df.to_hdf('df.h5', 'df')
File "/shared_directory/projects/env/lib/python3.6/site-packages/pandas/core/generic.py", line 1996, in to_hdf
return pytables.to_hdf(path_or_buf, key, self, **kwargs)
File "/shared_directory/projects/env/lib/python3.6/site-packages/pandas/io/pytables.py", line 279, in to_hdf
f(store)
File "/shared_directory/projects/env/lib/python3.6/site-packages/pandas/io/pytables.py", line 273, in <lambda>
f = lambda store: store.put(key, value, **kwargs)
File "/shared_directory/projects/env/lib/python3.6/site-packages/pandas/io/pytables.py", line 890, in put
self._write_to_group(key, value, append=append, **kwargs) …Run Code Online (Sandbox Code Playgroud) 使用羽毛包时(http://blog.cloudera.com/blog/2016/03/feather-a-fast-on-disk-format-for-data-frames-for-r-and-python-powered-通过-apache-arrow /)尝试编写一个简单的20x20数据帧,我不断收到一条错误,指出尚未支持跨步数据.我不相信我的数据是跨步的(或不同寻常的),我可以复制网站上给出的示例代码,但似乎无法让它与我自己的工作.以下是一些示例代码:
import feather
import numpy as np
import pandas as pd
tempArr = reshape(np.arange(400), (20,20))
df = pd.DataFrame(tempArr)
feather.write_dataframe(df, 'test.feather')
Run Code Online (Sandbox Code Playgroud)
最后一行返回以下错误:
FeatherError: Invalid: no support for strided data yet
Run Code Online (Sandbox Code Playgroud)
我在Ubuntu 14.04上运行它.我是否可能误解了有关熊猫数据帧的存储方式?
有没有办法使用pd.to_feather附加到.feather格式文件?
我也很好奇是否有人知道最大文件大小方面的一些限制,以及在读取.feather文件时是否可以查询某些特定数据(例如读取日期> 2017-03-31的行) ").
我喜欢能够存储我的数据帧和分类数据的想法.
我有羽毛格式文件sales.fea,我用它来交换python和R 之间的数据.
在RI中使用以下命令:
df = as.data.frame(feather::read_feather("sales.fea"))
Run Code Online (Sandbox Code Playgroud)
在python我用过:
df = feather.read_dataframe("sales.fea")
Run Code Online (Sandbox Code Playgroud)
将数据从该文件加载到内存到Spark实例的最快/最佳方法是什么pyspark?
我不想使用pandas来加载数据,因为它是我的19GB羽毛文件的段错误,由45GB csv创建.
我的想法是,Spark是如此时髦,也是羽毛,我希望有一些更本土化的方式,而不是通过次高效的临时解决方案.
我有一个数据框,其中包含不同数据类型的列,包括日期。不,在做了一些修改后,我想将其保存为羽毛文件,以便以后访问它。但我在以下步骤中收到错误
historical_transactions.to_feather('tmp/historical-raw')
ArrowNotImplementedError: halffloat
Run Code Online (Sandbox Code Playgroud) 使用pandas 中的 IO 工具可以将 a 转换为DataFrame内存中的羽化缓冲区:
import pandas as pd
from io import BytesIO
df = pd.DataFrame({'a': [1,2], 'b': [3.0,4.0]})
buf = BytesIO()
df.to_feather(buf)
Run Code Online (Sandbox Code Playgroud)
但是,使用相同的缓冲区转换回 DataFrame
pd.read_feather(buf)
Run Code Online (Sandbox Code Playgroud)
结果报错:
ArrowInvalid:不是羽毛文件
如何将 DataFrame 转换为内存中的羽化表示,并相应地转换回 DataFrame?
预先感谢您的考虑和回应。
feather ×10
pandas ×8
python ×6
apache-arrow ×2
pyarrow ×2
python-3.x ×2
apache-spark ×1
hdf ×1
parquet ×1
pyspark ×1
python-2.7 ×1
r ×1
vaex ×1