小编Gaj*_*are的帖子

如何在 python 中读取 34Gb stata (.dta) 文件

我正在尝试读取 34Gb Stata (.dta) 文件,但不断收到“MemoryError”消息,很明显我的 16Gb 内存不够用。

我尝试使用以下命令测试 11Mb Stata 文件:

dtafile = 'E:/test file.dta'
df = pd.read_stata(dtafile)
a = df.head()
print(a)
Run Code Online (Sandbox Code Playgroud)

我得到了正确的输出:

   app_id    inventor_id  ...  lagged_generality_FYnormalized       _merge
0  101985                 ...                        1.038381  matched (3)
1  102019  SCHOTTEK 2827  ...                        0.830110  matched (3)
2  102019  KUELLMER 2827  ...                        0.830110  matched (3)
3  102019   DICKNER 2827  ...                        0.830110  matched (3)
4  102562    VINEGAR 986  ...                        0.825088  matched (3)

[5 rows x 1448 columns]

Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)

但是当我对 34Gb 文件进行同样的尝试时,我收到了一条“MemoryError”消息。完整的错误消息是: …

python stata pandas

0
推荐指数
1
解决办法
521
查看次数

标签 统计

pandas ×1

python ×1

stata ×1