1.dataframe查找是否有空值及位置 , 参见:https://blog.csdn.net/htbeker/article/details/80071900
df['col'][df['col'].isnull().values==True] #查找空值
# 删除某列空值所在行数据
df['col'].isnull().value_counts()
df['col'] = df['col'].fillna('999')
df[(df.col== '999')].index.tolist() # 找到空值的索引 [37405, 37406, 104433, 104434, 104435, 120601, 120602]
df = df.drop([37405, 37406, 104433, 104434, 104435, 120601, 120602])
# dataframe 重新索引
df= df.reset_index(drop = True)
2.创建空dataframe, 添加数据
new_df = pd.DataFrame(columns=["score", "topic"]) #创建dataframe
for i in range(len(data_result['result'])):
print(i)
for j in data_result['result'][i]:
# 添加数据