#function to find all the columns in dataframe which are object and convert them to float def object_to_float(x): object_columns = df.select_dtypes(include=['object']).columns object_names = object_columns[1:] #only done in this case to handle sid for column in object_names: x[column] = x[column].astype(float) object_to_float(df) return x