I wish to round the values to the nearest even number within a dataframe.
Data
ID Q121 Q221 Q321 Q421 Q122 Q222 Q322 Q422
AA 5.9 9.5 6.6 11.4 6.8 7.8 4.5 8.6
BB 8.5 6.5 3.1 5.3 7.2 8.1 5.3 8.7
Desired
ID Q121 Q221 Q321 Q421 Q122 Q222 Q322 Q422
AA 6.0 10.0 6.0 12.0 6.0 8.0 4.0 8.0
BB 8.0 6.0 4.0 6.0 8.0 8.0 6.0 8.0
Doing
df.set_index(['ID']).round(df/2)*2
I only want to target the columns that contain values in them, so I am indexing the first column. I am still researching, any suggestion is appreciated.