将数据帧转储到json后,在回读的同时,大熊猫将所有索引和列名转换为日期。
ar_dict = '{"0.1":{"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0},"0.05":{"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0},"0.01":{"0.1":13,"0.2":13,"0.3":11,"0.4":8,"0.5":7,"0.6":5,"0.7":3,"0.8":0,"0.9":0},"0.005":{"0.1":113,"0.2":68,"0.3":46,"0.4":28,"0.5":20,"0.6":16,"0.7":12,"0.8":3,"0.9":2}}'
df_ar = pd.read_json(ar_dict)
df_ar
1970-01-01 00:00:00.100000 1970-01-01 00:00:00.050000 1970-01-01 00:00:00.010000 1970-01-01 00:00:00.005000
1970-01-01 00:00:00.100 0 0 13 113
1970-01-01 00:00:00.200 0 0 13 68
1970-01-01 00:00:00.300 0 0 11 46
1970-01-01 00:00:00.400 0 0 8 28
1970-01-01 00:00:00.500 0 0 7 20
1970-01-01 00:00:00.600 0 0 5 16
1970-01-01 00:00:00.700 0 0 3 12
1970-01-01 00:00:00.800 0 0 0 3
1970-01-01 00:00:00.900 0 0 0 2
尽管索引和列名是固定的-
idx = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]
columns = [0.1, 0.05, 0.01, 0.005]
有什么方法可以忽略这种自动转换,还是在读取json时定义列和索引?