TGViewer
Data Science & Machine Learning Data Science & Machine Learning @datasciencefun ยท 77.8K subscribers
Post #4132 6.9K
โœ… Data Cleaning in Pandas ๐Ÿ๐Ÿงน

๐Ÿ‘‰ In real projects, 80% of the work = Data Cleaning

Because raw data is always messy ๐Ÿ˜…

๐Ÿ”น 1. Why Data Cleaning?

Real-world data may have:
โŒ Missing values
โŒ Duplicate records
โŒ Wrong formats
โŒ Extra spaces

๐Ÿ‘‰ Cleaning makes data usable for analysis & ML.

๐Ÿ”ฅ 2. Handling Missing Values

โœ… Check Missing Values

df.isnull()
df.isnull().sum()

โœ… Remove Missing Values
df.dropna()

โœ… Fill Missing Values
df.fillna(0)

๐Ÿ‘‰ Replace missing values with 0 or mean.

๐Ÿ”น 3. Remove Duplicates

df.drop_duplicates()

๐Ÿ”น 4. Rename Columns

df.rename(columns={"Name": "Full_Name"}, inplace=True)

๐Ÿ”น 5. Change Data Types

df["Age"] = df["Age"].astype(int)

๐Ÿ”น 6. Remove Extra Spaces

df["Name"] = df["Name"].str.strip()

๐Ÿ”น 7. Replace Values

df["City"] = df["City"].replace("NY", "New York")

๐Ÿ”น 8. Why This is Important?
โœ” Clean data = better insights
โœ” Clean data = better ML models
โœ” Used in every real-world project

๐ŸŽฏ Todayโ€™s Goal
โœ” Handle missing values
โœ” Remove duplicates
โœ” Fix data types
โœ” Clean text data

๐Ÿ‘‰ Double Tap โค๏ธ For More
  • โค 26
  • ๐Ÿ‘ 5
  • ๐Ÿ”ฅ 1
More from @datasciencefun
  1. Oct 15, 2026Post #4665
  2. Oct 15, 2026Post #4664
  3. Oct 15, 2026Post #4663
  4. Oct 15, 2026Post #4662
  5. Oct 13, 2026๐—ง๐—ข๐—ฃ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ข๐—จ๐—ฅ๐—ฆ๐—˜๐—ฆ ๐—ง๐—ข ๐—•๐—ข๐—ข๐—ฆ๐—ง ๐—ฌ๐—ข๐—จ๐—ฅ ๐—ฆ๐—ž๐—œ๐—Ÿ๐—Ÿ๐—ฆ ๐—œ๐—ก ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ! Explorโ€ฆ
  6. Oct 12, 2026Used when you want to perform calculations for each department. Simple rule: DISTINCT โ†’ Giโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’