尝试使用Python将CSV文件转换为Parquet的记忆中
我正在尝试将一个非常大的CSV文件转换为Parquet。
我尝试了以下方法:
df1 = pd.read_csv('/kaggle/input/amex-default-prediction/train_data.csv')
df1.to_parquet('/kaggle/input/amex-default-prediction/train.parquet')
但是pd.read._csv
thrws 从内存错误
是否有任何方法可以转换为文件而不完全加载文件?
I am trying to convert a very large csv file to parquet.
I have tried the following method:
df1 = pd.read_csv('/kaggle/input/amex-default-prediction/train_data.csv')
df1.to_parquet('/kaggle/input/amex-default-prediction/train.parquet')
but pd.read_csv
throws Out Of Memory Error
Is there any way to convert to the file without loading it entirely ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了解决内存问题,您可以首先使用大熊猫的chunck方法导入数据,然后将每个chunck保存为镶木quet文件。因此,例如,对于您的情况,请创建一个文件夹“ train_data”,在此文件夹中,您可以保存与Chuncks相对应的不同的Parquet文件。
To solve the memory problem, you can first import the data with the chunck method of pandas and save each chunck as a parquet file. So for example for your case, create a folder "train_data", and in this folder you save the different parquet files that correspond to the chuncks.