[英]AttributeError: __enter__ while using with statement with read_parquet
I want to open all parquet files existing in a specific folder and draw a scatter plot with it. 我想打开特定文件夹中存在的所有镶木地板文件,并使用它绘制散点图。 I used following code:
我使用以下代码:
for file in glob.glob("*.parquet"):
with pd.read_parquet(file, columns=["cordx", "cordy"]) as df:
make some scaterplot
Files can be found as I let python print the file
sucessfully. 我可以让python成功打印文件,因此可以找到
file
。 But i recive AttributeError: __enter__
. 但是我
AttributeError: __enter__
。 And read_parquet
is the corredct way to open those files. 而
read_parquet
是打开这些文件的正确方法。 When I dont use columns=[ ] I get pyarrow.lib.ArrowIOError: Arrow error: Out of memory: malloc of size 9771487328 failed
error because the files are very big. 当我不使用column = []时,我得到
pyarrow.lib.ArrowIOError: Arrow error: Out of memory: malloc of size 9771487328 failed
因为文件很大。 So its necessary to load only those columns. 因此仅加载那些列是必要的。
This error tells you that pandas.read_parquet
does not have a context manager implemented which means that you cannot call it using with
because __enter__
and __exit__
methods are missing. 该错误告诉您
pandas.read_parquet
没有实现上下文管理器,这意味着您无法使用with
调用with
因为__enter__
和__exit__
方法。 Look in here How to read a Parquet file into Pandas DataFrame? 在这里查看如何将Parquet文件读入Pandas DataFrame?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.