[EDA] : To convert all objects columns to float

PHOTO EMBED

Thu Jul 21 2022 10:57:10 GMT+0000 (Coordinated Universal Time)

Saved by @instadeath

#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
content_copyCOPY

http://localhost:8889/notebooks/Desktop/Swiggy/2. Codes/Python notebooks/Widgets contribution to HM.ipynb