【问题标题】:Pandas read_json - Stop convert index to datetimePandas read_json - 停止将索引转换为日期时间
【发布时间】:2020-11-06 19:27:39
【问题描述】:

我在 a.json 文件中有以下数据。

{
  "1000000000": {
    "TEST": 2
  }
}

import pandas as pd
df = pd.read_json(r"a.json", dtype= str, orient='index', convert_dates=False)
print(df)

获取输出为:

                TEST
2001-09-09 01:46:40    2

预期:

                TEST
1000000000         2

【问题讨论】:

    标签: json pandas


    【解决方案1】:

    read_json中需要参数convert_axes=False:

    你可以这样使用它

    import pandas as pd
    df = pd.read_json("a.json", dtype= str, orient='index',convert_axes=False ,convert_dates=False)
    print(df)
    

    【讨论】:

      猜你喜欢
      • 2018-10-30
      • 2017-07-11
      • 1970-01-01
      • 2018-03-03
      • 1970-01-01
      • 2020-01-16
      • 2016-10-05
      相关资源
      最近更新 更多