擅长:python、mysql、java
<p>当您传递<code>chunksize</code>或<code>iterator=True</code>时,<code>pd.read_table</code>将返回一个TextFileReader,您可以对其进行迭代或调用<code>get_chunk</code>。所以您需要在<code>data</code>上迭代或调用<code>get_chunk</code>。在</p>
<p>所以对整个文件的正确处理可能看起来像</p>
<pre><code>import pandas as pd
data = pd.read_table('datafile.txt',sep='\t',chunksize=1000, iterator=True)
with open('data.csv', 'a') as f:
for chunk in data:
chunk[chunk.visits > 10].to_csv(f, sep=',', index=False, header=False)
</code></pre>