【发布时间】:2018-06-19 05:05:36
【问题描述】:
有很多关于 json 到 pandas 数据框的问题,但没有一个能解决我的问题。我正在练习这个看起来像这样的复杂 json 文件
{
"type" : "FeatureCollection",
"features" : [ {
"Id" : 265068000,
"type" : "Feature",
"geometry" : {
"type" : "Point",
"coordinates" : [ 22.170376666666666, 65.57273333333333 ]
},
"properties" : {
"timestampExternal" : 1529151039629
}
}, {
"Id" : 265745760,
"type" : "Feature",
"geometry" : {
"type" : "Point",
"coordinates" : [ 20.329506666666667, 63.675425000000004 ]
},
"properties" : {
"timestampExternal" : 1529151278287
}
} ]
}
我想使用pd.read_json() 直接将此 json 转换为 pandas 数据帧我的主要目标是提取 Id、坐标和时间戳外部。由于这是非常复杂的 json,pd.read_json() 的正常方式根本不会给出正确的输出。你能建议我吗,在这种情况下我该如何解决。预期的输出是这样的
Id,Coordinates,timestampExternal
265068000,[22.170376666666666, 65.57273333333333],1529151039629
265745760,[20.329506666666667, 63.675425000000004],1529151278287
【问题讨论】:
-
我不明白从计算机的角度来看,一个结构是如何被认为是复杂的。
标签: python json pandas dataframe