我有一个带有DateTime索引的数据框:
df.resample
我现在想要每30分钟选择一次行(从15.00开始)
所以,我尝试了resample.mean()
,但它给了我一个警告,即只能使用resample.sum()
或>>> df1=df['Conn_ses'].resample('30Min')
>>> df1.head()
/.../W10 data analysis.py:1: FutureWarning: .resample() is now a deferred operation
use .resample(...).mean() instead of .resample(...)
from datetime import datetime
DateTime
2018-07-02 14:30:00 332.000000
2018-07-02 15:00:00 323.333333
2018-07-02 15:30:00 314.000000
2018-07-02 16:00:00 296.666667
2018-07-02 16:30:00 248.833333
Freq: 30T, Name: Conn_ses, dtype: float64
。但是,我不需要,我想保留原来的价值观。这是我使用resample时的结果:
function initMap() {
var uluru = {lat: -25.363, lng: 131.044};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: uluru
});
var contentString = '<div id="content"><h1 id="firstHeading">Welcome</h1>'+
'<div id="bodyContent">'+
'<p><b>Hello</b>, Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>'+
'</div>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var marker = new google.maps.Marker({
position: uluru,
map: map,
title: 'Uluru (Ayers Rock)'
});
marker.addListener('click', function() {
infowindow.open(map, marker);
});
infowindow.open(map,marker);
}
在这种情况下,重采样方法是正确的吗?如果没有,我该如何处理这个问题?
答案 0 :(得分:1)
我相信你需要:
df1 = df['Conn_ses'].resample('30Min').first()
print (df1)
DateTime
2018-07-02 14:30:00 332
2018-07-02 15:00:00 328
Freq: 30T, Name: Conn_ses, dtype: int64