I am doing a project which requires data cleaning. I wanted to clear columns which have strings in them.
What I planned to do is define a function and then use it. I wrote the function but it is not working.
Here's the function:-
def removeStringColumns(df):
for i in (df.columns):
if type(df[i][0]) == "str":
df = df.drop(df[i], axis=1)
return df
And here's how I call it.
data = pd.read_csv("./data.csv")
data.dropna()
data = data.replace(np.nan, 0)
data = removeStringColumns(data)