use*_*827 3 python memory pandas
我有一个包含约 50,000 行和 300 列的 csv 文件。执行以下操作会导致 Pandas (python) 中出现内存错误:
merged_df.stack(0).reset_index(1)
Run Code Online (Sandbox Code Playgroud)
数据框如下所示:
GRID_WISE_MW1 Col0 Col1 Col2 .... Col300
7228260 1444 1819 2042
7228261 1444 1819 2042
Run Code Online (Sandbox Code Playgroud)
我正在使用最新的 pandas (0.13.1),并且行数较少 (~2,000) 的数据帧不会出现该错误
谢谢!
所以它占用了我的 64 位 Linux (32GB) 内存,略小于 2GB。
In [5]: def f():
df = DataFrame(np.random.randn(50000,300))
df.stack().reset_index(1)
In [6]: %memit f()
maximum of 1: 1791.054688 MB per loop
Run Code Online (Sandbox Code Playgroud)
既然你没有具体说明。这在 32 位上根本不起作用(因为您通常无法分配 2GB 连续块),但如果您有合理的交换/内存,则应该可以工作。
| 归档时间: |
|
| 查看次数: |
5606 次 |
| 最近记录: |