Python数据帧重采样类型错误

Python数据帧重采样类型错误,python,dataframe,typeerror,Python,Dataframe,Typeerror,我有一个pd.DataFrame,我想每十分钟重新采样一次。 对于重采样,我对数据帧进行了如下索引: re_in = Re.set_index(pd.DatetimeIndex(Re['time'])) # index Re time time T WR WS WG U R RC

我有一个pd.DataFrame,我想每十分钟重新采样一次。 对于重采样,我对数据帧进行了如下索引:

re_in = Re.set_index(pd.DatetimeIndex(Re['time'])) # index Re
time                 time                   T   WR    WS    WG   U    R   RC                                                                           
2017-06-22 00:00:00  2017-06-22 00:00:00  21.8  159   5.8   7.9  66  0.0  0.0   
2017-06-22 00:05:00  2017-06-22 00:05:00  21.9  173   9.0  11.9  65  0.0  0.0   
2017-06-22 00:10:00  2017-06-22 00:10:00  21.9  145   4.0   4.0  66  0.0  0.0   
2017-06-22 00:15:00  2017-06-22 00:15:00  21.9  158   6.8   7.9  67  0.0  0.0   
2017-06-22 00:20:00  2017-06-22 00:20:00  21.9  149   6.4   7.9  68  0.0  0.0   
2017-06-22 00:25:00  2017-06-22 00:25:00  21.9  156   4.7   7.9  68  0.0  0.0   
2017-06-22 00:30:00  2017-06-22 00:30:00  21.8  153   3.2   4.0  69  0.0  0.0 
导致重新加载的结果如下所示:

re_in = Re.set_index(pd.DatetimeIndex(Re['time'])) # index Re
time                 time                   T   WR    WS    WG   U    R   RC                                                                           
2017-06-22 00:00:00  2017-06-22 00:00:00  21.8  159   5.8   7.9  66  0.0  0.0   
2017-06-22 00:05:00  2017-06-22 00:05:00  21.9  173   9.0  11.9  65  0.0  0.0   
2017-06-22 00:10:00  2017-06-22 00:10:00  21.9  145   4.0   4.0  66  0.0  0.0   
2017-06-22 00:15:00  2017-06-22 00:15:00  21.9  158   6.8   7.9  67  0.0  0.0   
2017-06-22 00:20:00  2017-06-22 00:20:00  21.9  149   6.4   7.9  68  0.0  0.0   
2017-06-22 00:25:00  2017-06-22 00:25:00  21.9  156   4.7   7.9  68  0.0  0.0   
2017-06-22 00:30:00  2017-06-22 00:30:00  21.8  153   3.2   4.0  69  0.0  0.0 
我尝试使用以下代码采集样本:

av_temp['RE_mean'] = re_in.T.resample("10T").mean() # average Re
但我得到了一个错误:

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
    execfile(filename, namespace)

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "M:/Python/Testveld/Software/selecting_date_temperature_av.py", line 234, in <module>
    av_temp['WH_mean'] = re_in.T.resample(SAMPLE).mean() # average renkforce

  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py", line 4212, in resample
    base=base, key=on, level=level)

  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\tseries\resample.py", line 944, in resample
    return tg._get_resampler(obj, kind=kind)

  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\tseries\resample.py", line 1057, in _get_resampler
    "but got an instance of %r" % type(ax).__name__)

TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Index' 
如何解决此问题?

T是pandas.DataFrame的一个属性,它将创建您的DataFrame,您需要使用['T']:

是否要对T列重新采样?