我有下一个JSON文件:
{
"_id": "2105291180380642",
"firstKey": "1651560",
"secondKey": "2108270",
"thirdKey": "4725",
"fourthKy": "5",
"userId": "fjbcjsda",
"subscription": "null",
"deviceId": "android_ST25i_1264-3545",
"appId": "1.4",
"sample": "false",
"auth": "null",
"usageType": "s",
"type": "l",
"occurredAt": "1374781560092"
}
我可以在JSONlit.com上证明这一点并获取valid JSON
。
在Pandas Python中导入此文件(文件内容仅来自一行)后,尝试使用以下命令创建一些DataFrame:
import pandas as pd
df = pd.read_json('test.json')
或
df = pd.read_json('test.json',orient='columns')
我总是得到一条错误信息:
If using all scalar values, you must must pass an index
如何使用read_json
将JSON文件导入DataFrame?此命令目前还不知道有效的JSON文件。我的熊猫版本是0.13.1