我有以下日期框架。我想groupby意味着每小时,但仍保留小时日期时间信息。
Type Class Value Date
Plant1 Plant 5498 24/01/2018
Plant1 Plant 5998 25/01/2018
Plant1 Plant 5815 26/01/2018
Veg1 Vegetable 5426 24/01/2018
Veg1 Vegetable 5464 25/01/2018
Veg1 Vegetable 3756 26/01/2018
我希望在 date A I r z
0 2017-08-01 00:00:00 3 56 4 6.
1 2017-08-01 00:00:01 3 57 1 6
2 2017-08-01 00:00:03 3 58 9 6
3 2017-08-01 00:00:05 3 52 10 2.
4 2017-08-01 00:00:06 3 50 1 1
df.groupby(df['date'].dt.hour).mean()
date A I r z
0 3 56 4 6.
1 3 57 1 6
2 3 58 9 6
3 3 52 10 2.
4 3 50 1 1
datetime64 [ns]
如何在Python中实现此输出?
所需输出:
2017-08-01 00:00:00
答案 0 :(得分:3)
使用var web = clientContext.Web;
var list = web.Lists.GetByTitle("DiscussionBoard");
//get disscussion by disscussion item id, for production, it should be based on caml query
var item = list.GetItemById(2);
//set best reply by reply item id, for production, it should be based on caml query
item["BestAnswerId"]=7;
item.Update();
clientContext.ExecuteQuery();
resample
数据输入
df.set_index('date').resample('H').mean()
Out[179]:
A I r z
date
2017-08-01 00:00:00 3.0 55.75 6.0 5.0
2017-08-01 01:00:00 NaN NaN NaN NaN
2017-08-01 02:00:00 NaN NaN NaN NaN
2017-08-01 03:00:00 3.0 50.00 1.0 1.0