1.解析json
import pandas
import json
d = pandas.read_json(path_or_buf='***.json', lines=True, encoding='utf-8')
l = d['l']
#l样式:{"positive_prob": 0.984951, "confidence": 0.966558, "negative_prob": 0.0150489, "sentiment": 2}
def deal(str):
if str.startswith('{'):
name = json.loads(str)
return name["positive_prob"]
d["positive_prob"] = l.apply(deal)
2.遍历dataframe
for index,row in d.describe().iterrows():
print(index)
print(row)
print('###################')
3.显示设置
pandas.set_option('display.width', 1000) # 设置字符显示宽度
pandas.set_option('display.max_rows', None) # 设置显示最大行