<p>这对我有用</p>
<pre><code>import pandas as pd
filename = 'precincts-with-results.geojson.gz'
df = pd.read_json(filename)
features = df['features']
properties = [_['properties'] for _ in features.values]
collect_properties = {_: list() for _ in properties[0].keys()}
for record in properties:
for col_name, value in record.items():
collect_properties[col_name].append(value)
new_df = pd.DataFrame.from_dict(collect_properties).set_index('GEOID')
print(new_df)
</code></pre>
<p>结果看起来像</p>
<pre><code> votes_dem votes_rep ... votes_per_sqkm pct_dem_lead
GEOID ...
05047-1-A (Oz Wd 1) 79.0 279.0 ... 54.2 -54.6
05149-11 - Dutch Creek 6.0 31.0 ... 0.3 -67.6
05081-Franklin Township 53.0 383.0 ... 3.8 -73.3
05027-McNeil City 64.0 68.0 ... 41.9 -2.9
05027-Taylor Township 67.0 342.0 ... 1.7 -65.0
... ... ... ... ...
56007-01-01 173.0 300.0 ... 21.8 -26.1
56045-05-01 70.0 390.0 ... 259.5 -66.7
56045-05-02 67.0 376.0 ... 66.5 -68.1
56045-05-03 63.0 419.0 ... 141.4 -71.5
56041-130 168.0 654.0 ... 1.7 -57.1
[146596 rows x 5 columns]
</code></pre>