<p>我不知道你所需要的是否就是你所期望的输出。
我给你的解决方案是“脏”(更多的元素和列标签放在第一位)
你可以设法清理它,并把它的格式,你需要的。因为您没有提供一段代码来开始,所以您可以完成它。
最终您会发现stackoverflow的目的不是让人们为您编写代码,而是让人们帮助您完成正在尝试的代码。你知道吗</p>
<pre><code>import json
import pandas as pd
#open and reading of the json:
with open('netgear.json','r') as jfile:
data = jfile.read()
info = json.loads(data)
#json into content
words,tags = info['Text'].split(),info['Entities']
#list to handle the Entities
prelist = []
for i in tags:
j = list(i.values())
#['ORGANIZATION ', 'Netgear']
#['DEVICE ', 'Nighthawk AC1900']
prelist.append(j)
#DataFrames to be merged
dft = pd.DataFrame(prelist,columns=['TAG','WORD'])
dfw = pd.DataFrame(words,columns=['WORD'])
#combine the dataFrames and NaN into 0
df = dfw.merge(dft, on='WORD', how='outer').fillna(0)
</code></pre>
<p>这是输出:</p>
<pre><code> WORD TAG
0 I 0
1 I 0
2 currently 0
3 use 0
4 a 0
5 Netgear ORGANIZATION
6 Nighthawk 0
7 AC1900. 0
8 find 0
9 it 0
10 reliable. 0
11 Nighthawk AC1900 DEVICE
</code></pre>