【发布时间】:2020-04-26 16:03:05
【问题描述】:
我的 JSON (~500mb) 文件有多个 JSON 对象,实际上我只需要使用“customer_id”列。当我执行下面的代码时,它会给出内存错误。
with open('online_pageviews.json') as f:
online_pageviews = pd.DataFrame(json.loads(line) for line in f)
这是“online_pageviews.json”中 JSON 对象的示例
{
"date": "2018-08-01",
"visitor_id": "3832636531373538373137373",
"deviceType": "mobile",
"pageType": "product",
"category_id": "6365313034",
"on_product_id": "323239323839626",
"customer_id": "33343163316564313264"
}
有没有办法只使用“customer_id”列? 我该怎么做才能加载这个文件?
【问题讨论】:
-
你试过使用
pandas.read_json吗? -
它也会出现内存错误
标签: python json pandas bigdata data-science