Converting Non-Numeric Data to Numeric
Conversion
Use pd.to_numeric function to convert the column to numeric vales
- Non-Numeric Values: Non-numeric entries(e.g., dashes, empty strings) are automatically converted to
NaN
Handling NaN Values
- Drop NaN Values:
- Method: Use
dropna()to remove rows where column containsNaN - Result: Rows with missing or invalid data are removed, leaving only valid numeric entries
- Method: Use
- Fill NaN Values:
- Method: Use
fillna()to replaceNaNwith a default value (e.g., 0) or a statistical measure(e.g., the median)
- Method: Use