Nov-15-2019, 11:48 AM
I don't know whether it addresses your problem:
import pandas as pd data = ['2019-05-02 00:03:00', '2019-05-02 00:08:00', '2019-05-02 00:13:00', '2019-05-02 00:18:00', '2019-05-02 00:23:00', '2019-05-02 00:28:00', '2019-05-02 00:33:00'] df = pd.DataFrame({'num': range(len(data))}, index=pd.to_datetime(data))It will create following DataFrame with DatetimeIndex:
Output: num
2019-05-02 00:03:00 0
2019-05-02 00:08:00 1
2019-05-02 00:13:00 2
2019-05-02 00:18:00 3
2019-05-02 00:23:00 4
2019-05-02 00:28:00 5
2019-05-02 00:33:00 6
Now we can set num value based on time:df.iloc[df.index.indexer_between_time('00:13:00', '23:59:00')] = 20Which will give:
Output: num
2019-05-02 00:03:00 0
2019-05-02 00:08:00 1
2019-05-02 00:13:00 20
2019-05-02 00:18:00 20
2019-05-02 00:23:00 20
2019-05-02 00:28:00 20
2019-05-02 00:33:00 20
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.