I know this question was asked before but each case is different... My plea is this:
df = pd.read_csv(‘file.csv’)
# convert the string into a datetime object
time = pd.to_datetime(df.dttm_utc)
Month=time.dt.month
Day=time.dt.day
Hour=time.dt.Hour
InDayLightSavings=True
if (Month<3): InDayLightSavings=False
if (Month==3) and (Day<11) and (Hour<2): InDayLightSavings=False
if (Month>11): InDayLightSavings=False
if (Month==11) and (Day>4)and (Hour>=2): InDayLightSavings=False
if (InDayLightSavings):
time=time-datetime.timedelta(hours=1)
And it returns, as you guessed correctly,Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). I used this with timestamp, changing it to an ISO8601 before and this method works but it doesn't work for series apparently. And I tried adding .any() and it doesn't work. I also change and to & as suggested in other thread. A par of my file.csv looks like this, running til end of 2012:
timestamp dttm_utc value
1325376300 2012-01-01 0:05:00 16.9444
1325376600 2012-01-01 0:10:00 16.6837
1325376900 2012-01-01 0:15:00 16.6837
1325377200 2012-01-01 0:20:00 16.9444
1325377500 2012-01-01 0:25:00 16.1623
1325377800 2012-01-01 0:30:00 16.6837
3/13/2016 1:00 51
3/13/2016 1:15 48
3/13/2016 1:30 50.4
3/13/2016 1:45 51
3/13/2016 3:00 47.4
3/13/2016 3:15 49.8
3/13/2016 3:30 51
3/13/2016 3:45 51
3/13/2016 4:00 48.6
Any help is appreciated.Thank you!