I have written the following function to delete the rows for Daylight Saving Time in a pandas dataframe as not every column has data for the hour of switching:
def hrsDSTdelete (df):
import pandas as pd
hrsDSTadjust = ['2000-03-26 02:00:00', ... '2012-03-25 02:00:00', '2013-03-31 02:00:00']
for DSTvalue in hrsDSTadjust:
if DSTvalue in df.index :
df = df.drop(pd.Timestamp(DSTvalue))
print 'DST hour: ', DSTvalue, " deleted!"
return df
pass
As this seems to work when deleting single rows, the following error message occurs when trying to do it with this loop:
exceptions.TypeError: 'Timestamp' object is not iterable
I have tried also with
df = df.ix[DSTvalue].drop
but this does not seem to delete the row in the dataframe. Has anyone got an idea what I am doing wrong?