我正在尝试将数据帧转换为json,以便使用API上传到Google表格。我没有错误,但是下面的代码给出了一个空的json数据。任何帮助将不胜感激。
数据帧BTCJPY
示例:
close high low market_cap open volume Volatility
timestamp
2019-04-06 23:59:05 5.653111e+05 5.816236e+05 5.577590e+05 9.967346e+12 5.627387e+05 1.891492e+12 NaN
2019-04-07 23:59:05 5.807896e+05 5.848436e+05 5.642018e+05 1.024129e+13 5.655849e+05 1.860643e+12 NaN
2019-04-08 23:59:09 5.896111e+05 5.928508e+05 5.738326e+05 1.039793e+13 5.795867e+05 1.912040e+12 0.008621
2019-04-09 23:59:06 5.783351e+05 5.877751e+05 5.741640e+05 1.020004e+13 5.877751e+05 1.635807e+12 0.024263
2019-04-10 23:59:05 5.910173e+05 6.017952e+05 5.764577e+05 1.042481e+13 5.776479e+05 1.720986e+12 0.029029
2019-04-11 23:59:04 5.653437e+05 5.976868e+05 5.600758e+05 9.973065e+12 5.944335e+05 1.848087e+12 0.046222
我的代码:
BTCJPY = pd.DataFrame.from_records(used_list)
BTCJPY['timestamp'] = pd.to_datetime(BTCJPY['timestamp'])
BTCJPY['Volatility'] = BTCJPY['close'].pct_change().dropna().rolling(2).std().dropna()
BTCJPY = BTCJPY.set_index('timestamp')
BTCJPY = BTCJPY.to_json()