I cannot convert data types in my dataframe to float from string (they are numerical values as string or empty strings):
calcMeanPrice_df = dessertApples_df.iloc[:, 5:17] #slice of columns
for col in calcMeanPrice_df: #iterate columns
pd.to_numeric(col, errors = 'coerce') #attempt to convert to numeric
calcMeanPrice_df.dtypes #return data column types
Out[21]:
4 object
5 object
6 object
7 object
8 object
9 object
10 object
11 object
12 object
13 object
14 object
15 object
dtype: object
What am i doing wrong here?
to_numericdoes not work inplace, you need to assign its return value someplace