Aishwarya Nevrekar Profile picture
I post about data science and memes. Chapter Lead at Omdena Mumbai Chapter Your only limit is your mind. DM for Collaborations 📩

May 3, 2023, 8 tweets

Master data cleaning in pandas like a pro with these simple functions.

Data cleaning is a critical step in any data analysis project

Learn to clean messy datasets with these easy steps.

A thread🧵👇

In pandas, you can use functions like .dropna(), .fillna(), and .replace() to clean up your data.

For example, let's say you have a data frame with missing values like this:

1. The .dropna() function removes any rows with missing values.

For example, you can use df.dropna() to drop any rows with missing values from your data frame called "df":

2. The .fillna() function replaces missing values with a specified value.

For example, you can use df.fillna(0) to replace any missing values in your data frame called "df" with 0:

3. The .replace() function replaces specified values with another value.

For example, you can use df.replace('Yes', 'True') to replace all instances of 'Yes' in your data frame called "df" with 'True':

4. Use functions like .str.lower() and .str.upper() to convert string values to lowercase or uppercase, respectively.

For example, you can use df['City'].str.lower() to convert all values in the 'City' column of your data frame to lowercase:

With these simple functions, you can quickly and easily clean up your data in pandas and prepare it for analysis! #pandas #datacleaning #datascience

Thank you so much for reading this, for more follow @nevrekaraishwa2

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling