I have a dataframe of columns that I would like to convert to numeric, like so:
for col in df.columns[22:33]:
df[col] = pd.to_numeric(df[col], errors = 'coerce')
Which works great. However whenever I try to include more than a single range, like so:
for col in df.columns[22:66, 68, 69, 71, 72, 74:79, 81:86, 88, 89,91:94 ]:
df[col] = pd.to_numeric(df[col], errors = 'coerce')
I get the error,
IndexError: too many indices for array
Is there a way around this, I would like to not have to do it over and over for each range. Thanks.