回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我以前从未使用过<code>json</code>文件。目前我正在做的就是:</p>
<pre><code>df = pd.read_json("precincts-with-results.geojson.gz")
df['features']
</code></pre>
<p>这是上面的结果:</p>
<pre><code>{'type': 'Feature',
'properties': {'GEOID': '05047-1-A (Oz Wd 1)',
'votes_dem': 79,
'votes_rep': 279,
'votes_total': 366,
'votes_per_sqkm': 54.2,
'pct_dem_lead': -54.6},
'geometry': {'type': 'MultiPolygon',
'coordinates': [[[[-93.88536364311612, 35.483758439321655],
[-93.8840470388143, 35.483727092097084],
[-93.88403177163875, 35.483726728784056],
[-93.88403177478405, 35.48372661335151],
[-93.87956152062023, 35.483586322546344],
[-93.87520339804045, 35.48339873745174],
[-93.87534656033012, 35.480428139370346],
[-93.87604589142236, 35.48045051399295], ...
</code></pre>
<p>我想要一个如下所示的数据帧:</p>
<pre><code>GEOID votes_dem votes_rep votes_total votes_per_sqkm pct_dem_lead
05047-1-A (Oz Wd 1) 79 279 366 54.2 -54.6
</code></pre>
<p>您可以在此处下载数据集(大小264MB)</strong>:<a href="https://int.nyt.com/newsgraphics/elections/map-data/2020/national/precincts-with-results.geojson.gz" rel="nofollow noreferrer">https://int.nyt.com/newsgraphics/elections/map-data/2020/national/precincts-with-results.geojson.gz</a></p>
<p>感谢您的帮助和代码</p>