TGViewer
Data science/ML/AI Data science/ML/AI @datascience_bds · 14.1K subscribers
Post #1052 1.56K
Data Cleaning in Python
Data cleaning is the process of detecting and correcting inaccurate, incomplete, or inconsistent data to improve data quality for analysis and modeling. It is a crucial step in any data science workflow.

Handling Missing Values
df.isnull().sum()        # Check missing values
df.dropna()              # Remove rows with missing values
df.fillna(0)             # Replace missing values


Removing Duplicate Data
df.duplicated()          # Identify duplicates
df.drop_duplicates()     # Remove duplicates


Correcting Data Types
df.dtypes                                                      #identify data types
df["age"] = df["age"].astype(int)               #convert age column to integer data type
df["date"] = pd.to_datetime(df["date"])    #convert date column to date data type


Renaming Columns
df.columns = df.columns.str.lower().str.replace(" ", "_")


Handling Inconsistent Data
df["gender"] = df["gender"].str.lower()   #convert to lower case
df["name"] = df["name"].str.strip()   


Clean data leads to more accurate analysis and reliable models. Python’s pandas library simplifies cleaning tasks such as handling missing values, duplicates, incorrect types, and inconsistencies.
  • ❤ 10
  • 👎 1
More from @datascience_bds
  1. Oct 13, 20261,000 AI/ML Acronyms & Operational Concepts
  2. Oct 12, 2026Roadmap to Learn SQL
  3. Oct 11, 2026🧮 Why does NumPy let you add a number to an entire matrix? Look at this: import numpy as…
  4. Oct 10, 2026document post
  5. Oct 9, 20268 RAG architectures for AI Engineers, visually explained:
  6. Oct 8, 2026document post
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 →