gpt4 book ai didi

json - 如何停止 Pandas Dataframe read_json 方法将我的时代转换为人类可读的字符串

转载 作者:行者123 更新时间:2023-12-01 00:37:43 24 4
gpt4 key购买 nike

我使用 to_json 方法来序列化我的数据帧,内容如下所示:

"1467065160244362165":"1985.875","1467065161029130301":"1985.875","1467065161481601498":"1985.875","1467065161486508221":"1985.875"

如何停止 read_json 方法将我的纪元值从 1467065160244362165 转换为类似 2016-06-28 06:57:23.786726222 的值。
这就是我调用 read_json 的方式:
data = pd.read_json(remote_result_fullpath, convert_dates=False)

最佳答案

对我来说有效:

import pandas as pd

#added {} to file
remote_result_fullpath = 'https://dl.dropboxusercontent.com/u/84444599/file.json'

data = pd.read_json(remote_result_fullpath,
convert_dates=False, #dont convert columns to dates
convert_axes=False, #dont convert index to dates
typ='series') #if need convert output to Series

print (data)
1467065160244362165 1985.875
1467065161029130301 1985.875
1467065161481601498 1985.875
1467065161486508221 1985.875

print (data.dtypes)
dtype: float64
float64

如果需要字符串添加 dtype :
data = pd.read_json(remote_result_fullpath, 
convert_dates=False,
convert_axes=False,
typ='series',
dtype='object')

print (data)
1467065160244362165 1985.875
1467065161029130301 1985.875
1467065161481601498 1985.875
1467065161486508221 1985.875

print (data.dtypes)
dtype: object
object

print (data.index)
Index(['1467065160244362165', '1467065161029130301', '1467065161481601498',
'1467065161486508221'],
dtype='object')

关于json - 如何停止 Pandas Dataframe read_json 方法将我的时代转换为人类可读的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39330334/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com