w3resource

Pandas Data Cleaning and Preprocessing: Exercises, Solutions with Explanation


This resource offers a total of 75 Pandas Data Cleaning and Preprocessing problems for practice. It includes 15 main exercises, each accompanied by solutions, detailed explanations, and four related problems.

More exercises focused on cleaning and preprocessing data, including dealing with outliers, duplicates, and data normalization.

[An Editor is available at the bottom of the page to write and execute the scripts.]


1. Handling Missing Data in Pandas

Write a Pandas program to fill missing values (NaN) in a DataFrame using fillna().

Click me to see the sample solution


2. Handling Duplicates in Pandas

Write a Pandas program to drop rows with missing data.

Click me to see the sample solution


3. Data Cleaning Techniques

Write a Pandas program to detect duplicates using duplicated() method.

Click me to see the sample solution


4. String Manipulation in Pandas

Write a Pandas program to remove duplicates rows from a DataFrame.

Click me to see the sample solution


5. Handling Outliers with Z-Score Method

Write a Pandas program to handle outliers in a DataFrame with Z-Score method.

Click me to see the sample solution


6. Normalizing Data with Min-Max Scaling

Write a Pandas program that normalizes data with Min-Max scaling.

Click me to see the sample solution


7. Binning Data into Categories

Write a Pandas program to bin data into categories.

Click me to see the sample solution


8. Converting Data Types and Column Operations

Write a Pandas program that handles text data with str.replace().

Click me to see the sample solution


9. Replacing Missing Data with Mean Value

Write a Pandas program to convert data types using astype().

Click me to see the sample solution


10. Removing Columns with Too Many Missing Values

Write a Pandas program to remove leading and trailing whitespace using str.strip().

Click me to see the sample solution


11. Reordering and Splitting Columns

Write a Pandas program to change column names to lowercase.

Click me to see the sample solution


12. Dropping Rows with Missing Data

Write a Pandas program to replacing missing data with mean value.

Click me to see the sample solution


13. Changing Column Names to Lowercase

Write a Pandas program to remove columns with too many missing values.

Click me to see the sample solution


14. Reordering Columns in a DataFrame

Write a Pandas program to reorder columns in a DataFrame.

Click me to see the sample solution


15. Splitting a Column into Multiple Columns

Write a Pandas program to split a column into multiple columns.

Click me to see the sample solution


Python-Pandas Code Editor:

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.

Test your Python skills with w3resource's quiz



Follow us on Facebook and Twitter for latest update.