![](/img/trans.png)
[英]How to read an excel dataframe from a private GitHub repository using pandas?
[英]How to read and write files from disk using the pandas dataframe?
我將要處理非常大的數據文件(許多GB)。 我將不得不讀取這些文件並寫入這些文件。 因此,我將不能依靠RAM來存儲數據,並且需要從磁盤讀取和寫入文件。
我熟悉pandas庫提供的read_csv
和to_csv
選項。 但是,我不確定read csv
函數是先讀取文件,然后將其存儲在RAM上還是直接從磁盤讀取文件。
使用熊貓從磁盤讀取和寫入文件的最佳方法是什么?
pandas.read_csv
會將整個文件讀入內存。 如果只需要特定的列,則可以使用usecols
參數指定列的子集,而pandas只加載那些列。
由於文件不適合內存,您可以使用split在磁盤上拆分文件,然后對塊執行所有操作。
一個簡單的替代方法是使用read_csv
從dask.dataframe從DASK庫。
從文檔中:
A Dask DataFrame is a large parallel dataframe composed of many smaller Pandas dataframes, split along the index. These pandas dataframes may live on disk for larger-than-memory computing on a single machine, or on many different machines in a cluster.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.