将系列对象转换为json并将其写入本地驱动器

问题描述

我正在尝试将pd.series输出转换为格式为 [{“ Name”:0},{“ Outlier of Outliers”:4},{“ Age”:4}的json字符串, {“ Photo”:0}] 根据截图使用 Sum_Outliers 输出,并将json文件写入我的本地驱动器。以下是我尝试使用的代码。如果有人可以帮助我将系列转换为pandas数据框并用类似的json编写,那也很好

#Output to be written
import os
import json
os.chdir(Output)

ini_string = {'Columns': sum_Outliers}

# printing initial json 
ini_string = json.dumps(ini_string)

# converting string to json 
final_dictionary = json.loads(ini_string) 

with open('Optimal_K_value_result.txt','w') as json_file:
  json.dump(final_dictionary,json_file)

enter image description here

预先感谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)