Data Cleaning with Pandas
Pandas से Data Cleaning
What is Pandas Data Cleaning?
Pandas Data Cleaning means data cleaning fixes missing values, duplicate rows, wrong data types and inconsistent entries.
In real programs, this topic helps in removing duplicates. Learn the idea first, then type the program yourself and compare the output.
| Point | Details |
|---|---|
| Course Area | Data Science Tools and concepts used to analyse, clean and present data. |
| Main Use | removing duplicates |
| Example File | pandas-data-cleaning.py |
| Practice Focus | Run, change values, and explain the output line by line. |
Why should you learn this?
- It is useful for removing duplicates.
- It connects with filling missing values.
- It improves your ability to read, write and debug Python programs.
Important Terms
These terms are used directly in this lesson. Understand them before memorising the code.
| Term | Meaning |
|---|---|
| missing values | Blank or unavailable data values. |
| duplicates | Repeated records in data. |
| fillna | fillna is an important term in this topic. |
| dropna | dropna is an important term in this topic. |
| astype | astype is an important term in this topic. |
Syntax / Basic Pattern
The simple pattern is: prepare data, apply the concept, then show the result.
import pandas as pd
df = pd.DataFrame({"Name": ["Aarav", "Riya", "Riya"], "Marks": [82, None, None]})
df = df.drop_duplicates()
df["Marks"] = df["Marks"].fillna(0)
print(df)Complete Example Program
import pandas as pd
df = pd.DataFrame({"Name": ["Aarav", "Riya", "Riya"], "Marks": [82, None, None]})
df = df.drop_duplicates()
df["Marks"] = df["Marks"].fillna(0)
print(df)Expected Output
Program Explanation
import pandas as pdimports ready-made features from a module/library.df = pd.DataFrame({"Name": ["Aarav", "Riya", "Riya"], "Marks": [82, None, None]}stores a value in df.df = df.drop_duplicates()stores a value in df.df["Marks"] = df["Marks"].fillna(0)stores a value in df["Marks"].print(df)displays information or calculated result on the screen.
Where will you use it?
- Removing duplicates.
- Filling missing values.
- Fixing column data types.
Common Mistakes
- Analysing data before checking missing values, duplicates and data types.
- Changing original data without keeping a clean copy.
- Creating charts without title, labels or explanation.
Practice Tasks
- Type the program in
pandas-data-cleaning.pyand run it. - Change input values or sample data and observe the new output.
- Create one example related to removing duplicates.
- Write 5 lines explaining the logic in your own words.
Summary
Pandas Data Cleaning is not a theory-only topic. You should be able to explain the meaning, write the example, run it successfully, and use it in a small practical program.
Pandas Data Cleaning क्या है?
Pandas Data Cleaning ka matlab hai: Data cleaning fixes missing values, duplicate rows, wrong data types and inconsistent entries. Simple words me, ye topic practical Python programs likhne me direct use hota hai.
Is topic ko sirf definition ke liye nahi, balki removing duplicates jaise real examples ke liye practice karein.
यह क्यों सीखना जरूरी है?
- Ye removing duplicates me kaam aata hai.
- Ye filling missing values se bhi connected hai.
- Isse aap code ka output aur errors better samajh paate hain.
Important Terms
| Term | Meaning |
|---|---|
| missing values | Blank or unavailable data values. |
| duplicates | Repeated records in data. |
| fillna | fillna is an important term in this topic. |
| dropna | dropna is an important term in this topic. |
| astype | astype is an important term in this topic. |
Syntax / Basic Pattern
Basic idea: pehle data तैयार करें, phir Python logic apply करें, aur finally result display करें.
import pandas as pd
df = pd.DataFrame({"Name": ["Aarav", "Riya", "Riya"], "Marks": [82, None, None]})
df = df.drop_duplicates()
df["Marks"] = df["Marks"].fillna(0)
print(df)Complete Example Program
import pandas as pd
df = pd.DataFrame({"Name": ["Aarav", "Riya", "Riya"], "Marks": [82, None, None]})
df = df.drop_duplicates()
df["Marks"] = df["Marks"].fillna(0)
print(df)Expected Output
Program Explanation
import pandas as pdimports ready-made features from a module/library.df = pd.DataFrame({"Name": ["Aarav", "Riya", "Riya"], "Marks": [82, None, None]}stores a value in df.df = df.drop_duplicates()stores a value in df.df["Marks"] = df["Marks"].fillna(0)stores a value in df["Marks"].print(df)displays information or calculated result on the screen.
Practical Uses
- Removing duplicates.
- Filling missing values.
- Fixing column data types.
Common Mistakes
- Analysing data before checking missing values, duplicates and data types.
- Changing original data without keeping a clean copy.
- Creating charts without title, labels or explanation.
Practice Tasks
- Program ko
pandas-data-cleaning.pyfile me type karke run karein. - Values change karke output compare karein.
- removing duplicates par ek छोटा example banayen.
- Logic ko apne words me 5 lines me likhein.
सारांश
Pandas Data Cleaning ko tab complete maanenge jab aap iska meaning, example, output aur practical use clearly explain kar saken.