以下代码:
import pandas as pd
d = {
'col1': [1, 2, 3],
'col2': [4, 5, 6],
}
df = pd.DataFrame(d).to_json()
print(df)
给予:
{"col1":{"0":1,"1":2,"2":3},"col2":{"0":4,"1":5,"2":6}}
如何禁用枚举并将值转换为数组,所以输出是这样的?:
{"col1": [1, 2, 3], "col2": [4, 5, 6]}