I have a dataframe of a month excluding Saturday and Sunday, which was logged every 1 minute.
v1 v2
2017-04-03 09:15:00 35.7 35.4
2017-04-03 09:16:00 28.7 28.5
... ... ...
2017-04-03 16:29:00 81.7 81.5
2017-04-03 16:30:00 82.7 82.6
... ... ...
2017-04-04 09:15:00 24.3 24.2
2017-04-04 09:16:00 25.6 25.5
... ... ...
2017-04-04 16:29:00 67.0 67.2
2017-04-04 16:30:00 70.2 70.6
... ... ...
2017-04-28 09:15:00 31.7 31.4
2017-04-28 09:16:00 31.5 31.0
... ... ...
2017-04-28 16:29:00 33.2 33.5
2017-04-28 16:30:00 33.0 30.7
I have resample dataframe to get 1st and last value from each day.
res = df.groupby(df.index.date).apply(lambda x: x.iloc[[0, -1]])
res.index = res.index.droplevel(0)
print(res)
v1 v2
2017-04-03 09:15:00 35.7 35.4
2017-04-03 16:30:00 82.7 82.6
2017-04-04 09:15:00 24.3 24.2
2017-04-04 16:30:00 70.2 70.6
... .. ..
2017-04-28 09:15:00 31.7 31.4
2017-04-28 16:30:00 33.0 30.7
Now i want to have the data-frame organised as date with v1 of minimum timestamp and v2 of max timestamp of specific date.
Desired output:
v1 v2
2017-04-03 35.7 82.6
2017-04-04 24.3 70.6
... .. ..
2017-04-28 31.7 30.7