#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
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter