Cleaning DataLesson 11Free preview
Cleaning Wrong Format
This lesson is part of Pandas · All levels
Summary
Sometimes the numeric column contains text-type values so the calculation fails. For that, data type conversion needs to be done, for example with pd.to_numeric or astype. If the value cannot be converted, you can choose to discard the line or mark it for later handling.
Key points
- Column data type must be consistent with the content before it is analyzed
- Pd.to_numeric converts values to numeric with the option errors
- Astype is used to change the type of column explicitly
- The failed conversion line can be dealt with by dropping or transformed to empty
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.