I have a dataset "app_metadata.csv" with three column: item_id, category, description. item_id is integer number, category is a string, and description is a string. I loaded the dataset with the following code
app_metadata_df = pd.read_csv(app_metadata_csv_path)
However there is broken data in the dataset, for example there exist a row at which item_id is not a number but a text. I want to remove rows with invalid item_id value and convert the item_id column datatype to int. The following is what i have tried, first i call pd.to_numeric with errors='coerce'
app_metadata_df.loc["item_id"] = pd.to_numeric(app_metadata_df["item_id"], errors='coerce')
Then i drop NA value
app_metadata_df.loc["item_id"] = app_metadata_df.loc["item_id"].dropna()
And finally call the astype(int) to convert the datatype to int:
app_metadata_df.loc["item_id"] = app_metadata_df["item_id"].astype(int)
However, it throws the following error
invalid literal for int() with base 10: 'So'
It looks like to_numeric does not convert some invalid value to NAN. Why is this happening and how do i fix this ?