【发布时间】:2021-08-12 03:32:04
【问题描述】:
total_list = ['123456','00123456']
df = pd.read_json(json.dumps(total_list))
print(df)
结果是:
0
0 123456
1 123456
但我想保留'0',我该怎么做?
【问题讨论】:
标签: python json pandas dataframe
total_list = ['123456','00123456']
df = pd.read_json(json.dumps(total_list))
print(df)
结果是:
0
0 123456
1 123456
但我想保留'0',我该怎么做?
【问题讨论】:
标签: python json pandas dataframe
使用dtype == str:
total_list = ['123456','00123456']
df = pd.read_json(json.dumps(total_list), dtype=str)
print(df)
输出:
0
0 123456
1 00123456
【讨论】: