DataFrame 按行转json数据
import pandas as pd # 创建示例 DataFrame data = { 'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 35], 'Occupation': ['Engineer', 'Teacher', 'Doctor'] } df = pd.DataFrame(data) # 重置索引并将DataFrame转换为JSON格式的字符串 json_data = df.reset_index().to_json(orient='records',force_ascii=False) print(df) print("JSON format data:") print(json_data)
本文来自博客园,作者:OTAKU_nicole,转载请注明原文链接:https://www.cnblogs.com/nicole-zhang/p/17614381.html