AttributeError: ‘DatetimeIndexResampler‘ object has no attribute ‘resample‘

data_27 = pd.read_csv(r'E:\02-data\\0329_1556.csv', encoding='gbk', parse_dates=['TIMESTAMP'])
data_103 = pd.read_csv(r'E:\02-data\\0329_1545.csv',
                      encoding='gbk', parse_dates=['TIMESTAMP'])
data_27v1 = data_27.set_index('TIMESTAMP', drop=True)
data_103v1 = data_103.set_index('TIMESTAMP', drop=True)
df_Tai_27 = data_27v1.resample('10min')  
nr_in_27 = df_Tai_27.resample('10min')['WS_103m_x'].aggregate(len)  
Traceback (most recent call last):
  File "D:\python3.8.5\lib\site-packages\IPython\core\interactiveshell.py", line 3418, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "", line 4, in <module>
    nr_in_27 = df_Tai_27.resample('10min')['WS_103m_x'].aggregate(len)  
  File "D:\python3.8.5\lib\site-packages\pandas\core\resample.py", line 199, in __getattr__
    return object.__getattribute__(self, attr)
AttributeError: 'DatetimeIndexResampler' object has no attribute 'resample'

AttributeError: 'DatetimeIndexResampler' object has no attribute 'resample'
主要错误发生在
nr_in_27 = df_Tai_27.resample('10min')['WS_103m_x'].aggregate(len) # 求每个分仓段内数据的数量(多少行)
修改办法:

df.index = pd.DatetimeIndex(df.TimeStamp) 

data_27v1 = data_27.copy()
data_27v1.index = pd.DatetimeIndex(data_27v1.TIMESTAMP)
df_Tai_27 = data_27v1.resample('10min')['WS_27m_x'].aggregate(len)   

你可能感兴趣的:(bug,pandas,python,数据分析)