You should use .iterrows() instead of enumerate(df) . When you do enumerate(df) , you simply get column names that do not match your condition. iterrows() returns an index and a string (like pandas.Series ) each iteration.
But for your requirement, you can iterate over df.columns and do what you want in a vectorized way for each column. Example -
for col in df.columns: df.loc[df[col] < 0,col] += 360 df.loc[df[col] > 360,col] -= 360
I use columns instead of rows , assuming the number of columns will be much less than the number of rows, so we will do the actual loop for much less iterations (and using vectorized addition for more data at the same time).
Demo -
In [128]: df Out[128]: 0 1 2 3 timestamp 2013-04-17 05:00:00 4.335212 2655.140854 2655.140854 2655.140854 2013-04-17 05:10:00 2.224966 2655.140854 2655.140854 2655.140854 2013-04-17 05:20:00 2.409150 2655.140854 2655.140854 2655.140854 2013-04-17 05:30:00 2655.140854 2655.140854 2655.140854 2655.140854 In [134]: for col in df.columns: .....: df.loc[df[col] < 0,col] += 360 .....: df.loc[df[col] > 360,col] -= 360 .....: In [135]: df Out[135]: 0 1 2 3 timestamp 2013-04-17 05:00:00 4.335212 2295.140854 2295.140854 2295.140854 2013-04-17 05:10:00 2.224966 2295.140854 2295.140854 2295.140854 2013-04-17 05:20:00 2.409150 2295.140854 2295.140854 2295.140854 2013-04-17 05:30:00 2295.140854 2295.140854 2295.140854 2295.140854
source share