Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将每五分钟的数据平均为数据帧中的一个数据点_Python_Pandas_Time Series_Dataframe - Fatal编程技术网

Python 将每五分钟的数据平均为数据帧中的一个数据点

Python 将每五分钟的数据平均为数据帧中的一个数据点,python,pandas,time-series,dataframe,Python,Pandas,Time Series,Dataframe,我有一个像这样的熊猫数据框 1. 2013-10-09 09:00:05 2. 2013-10-09 09:01:00 3. 2013-10-09 09:02:00 4. ............ 5. ............ 6. ............ 7. 2013-10-10 09:15:05 8. 2013-10-10 09:16:00 9. 2013-10-10 09:17:00 我想通过平均每5分钟的数据并为其形成1个数据点来减小数据帧的大小,如下所示 1. 20

我有一个像这样的熊猫数据框

1. 2013-10-09 09:00:05
2. 2013-10-09 09:01:00
3. 2013-10-09 09:02:00
4.  ............
5.   ............
6.   ............
7. 2013-10-10 09:15:05
8. 2013-10-10 09:16:00 
9. 2013-10-10 09:17:00
我想通过平均每5分钟的数据并为其形成1个数据点来减小数据帧的大小,如下所示

1. 2013-10-09 09:00:05
2. 2013-10-09 09:01:00
3. 2013-10-09 09:02:00
4.  ............
5.   ............
6.   ............
7. 2013-10-10 09:15:05
8. 2013-10-10 09:16:00 
9. 2013-10-10 09:17:00
1. 2013-10-09 09:05:00
2. 2013-10-09 09:10:00
3. 2013-10-09 09:15:00
有人能帮我吗???

你可能想看看:

或者,默认参数为
how='mean'

df['Data'].resample('5Min')
例如:

>>> rng = pd.date_range('1/1/2012', periods=10, freq='Min')
>>> df = pd.DataFrame({'Data':np.random.randint(0, 500, len(rng))}, index=rng)
>>> df
                     Data
2012-01-01 00:00:00   488
2012-01-01 00:01:00   172
2012-01-01 00:02:00   276
2012-01-01 00:03:00     5
2012-01-01 00:04:00   233
2012-01-01 00:05:00   266
2012-01-01 00:06:00   103
2012-01-01 00:07:00    40
2012-01-01 00:08:00   274
2012-01-01 00:09:00   494
>>>
>>> df['Data'].resample('5Min')
2012-01-01 00:00:00    234.8
2012-01-01 00:05:00    235.4
你可以找到更多的例子