Problem 3: Fix Incorrect Data Types
Easypython
Learn the Concept: Data CleaningProblem Description
Write a Python program that takes a DataFrame where a numeric column ("age") was loaded as text, converts it to the correct integer type, and prints the data types before and after the fix.
Input
A DataFrame with an "age" column stored as strings.
Output
The data type of "age" before and after conversion.
Constraints
- All values in "age" are valid numeric strings (no invalid text).
Example Input
textage = ["21", "20", "19"]
Example Output
textBefore: object After: int64
Concepts Covered
.astype(), dtypes.
Related Problems
- Problem 1: Fix Inconsistent Text FormattingEasy · pythonSolve Problem
- Problem 2: Standardize Inconsistent CategoriesEasy · pythonSolve Problem
- Problem 4: Remove Irrelevant ColumnsEasy · pythonSolve Problem