重采样日期更改

时间:2018-10-12 03:45:06

标签: resampling

我已使用python中的重采样功能从2017年1月1日至2018年10月6日对EURUSD外汇对的10分钟频率数据进行了重采样。但是重新采样的数据为我提供了直到2018年12月7日的数据点,这是错误的。

我不确定为什么重新采样后日期会更改。请让我知道我要去哪里了。

这是我的代码以及重采样数据的最后5行。

import pandas as pd
df = pd.read_csv("C:\Users\Vidya\Desktop\EURUSD_1_BID_01.01.2017-06.10.2018.csv")
df['Local time'] = pd.to_datetime(df['Local time'], errors='coerce')
df.set_index(['Local time'],drop=True,inplace=True)
df.index = pd.to_datetime(df.index,format='%d/%m/%Y %H:%M')
df1 = df.tz_localize('UTC')
df2 = df1.tz_convert('US/Eastern')
df3 = df2.resample('10min').mean()
df3.isnull().any().any()
df4 = df3.fillna(method='ffill')
df4.isnull().any().any()
df4.to_csv(r'C:\Users\Vidya\Desktop\USDJPY10min311216-60918.csv')


                            Open     Close       Volume
Local time                                                
2018-12-07 14:10:00-05:00  112.6052  112.6080  58851.00001
2018-12-07 14:20:00-05:00  112.6344  112.6367  45211.00017
2018-12-07 14:30:00-05:00  112.6513  112.6526  68923.00004
2018-12-07 14:40:00-05:00  112.6672  112.6675  86051.00021
2018-12-07 14:50:00-05:00  112.6543  112.6526  76246.00085

0 个答案:

没有答案