Python-访问存储在熊猫数据框中的json元素

时间:2018-12-03 07:20:09

标签: python json pandas python-2.7

我在PostGIS数据库中存储了一组以字符串形式存储的json。为了处理这些json,我使用了熊猫的read_sql_query。我的PostgreSQL表和绘制的熊猫数据框只有两列:geojson | geojsonid。

json具有以下结构:

"{"crs":{
    "properties":{"name":"EPSG:4326"},
    "type":"name"
},
"features":[
    {"geometry":{"coordinates":[],"type":"LineString"},"properties":{"property1":"","property2":""},"type":"Feature"},
    {"geometry":{"coordinates":[],"type":"Point"},"properties":{"nodeno":1},"type":"Feature"},
    {"geometry":{"coordinates":[],"type":"Point"},"properties":{"nodeno":2},"type":"Feature"}],
"type":"FeatureCollection"}"

我想分别访问“几何”以及每个属性。

如何解析存储在数据框中的字符串以获取特定元素的属性?

0 个答案:

没有答案