I'm using Jupyter notebook. Default python kernel. 'numpy' and 'pandas' imported.
This column is named 'Period'. The value contains numbers and text like "Period". The data type is 'object'. I would like to delete the rows in which the value of column 'Period' is not a number.
What I tried to do is to first convert the column from object to numeric.
Name: Period, dtype: float64
Pandas operations like
to_numeric don't operate "in-place" by default. I recommend that you assign the result to a column in your dataframe.
df['Period_numbers'] = pd.to_numeric(df['Period'], errors='coerce')
Same goes with
In most cases you can pass
inplace=True to the method or function. But I really do recommend assigning the results instead.