Pandas Series and DataFrame
Pandas Series और DataFrame
What is Pandas Series and DataFrame?
Pandas Series and DataFrame means pandas provides Series and DataFrame for handling tabular data like Excel sheets and CSV files.
In real programs, this topic helps in reading CSV/Excel data. 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 | reading CSV/Excel data |
| Example File | pandas-series-dataframe.py |
| Practice Focus | Run, change values, and explain the output line by line. |
Why should you learn this?
- It is useful for reading CSV/Excel data.
- It connects with handling result tables.
- 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 |
|---|---|
| Series | One-dimensional labeled data structure in pandas. |
| DataFrame | Two-dimensional table structure in pandas. |
| columns | columns is an important term in this topic. |
| rows | rows is an important term in this topic. |
| head() | head() 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({
"Student": ["Aarav", "Riya", "Kabir"],
"Marks": [82, 94, 76]
})
print(df)
print("Average:", df["Marks"].mean())Complete Example Program
import pandas as pd
df = pd.DataFrame({
"Student": ["Aarav", "Riya", "Kabir"],
"Marks": [82, 94, 76]
})
print(df)
print("Average:", df["Marks"].mean())Expected Output
Program Explanation
import pandas as pdimports ready-made features from a module/library.df = pd.DataFrame({stores a value in df."Student": ["Aarav", "Riya", "Kabir"],performs the next step of the program logic."Marks": [82, 94, 76]performs the next step of the program logic.})performs the next step of the program logic.print(df)displays information or calculated result on the screen.print("Average:", df["Marks"].mean())displays information or calculated result on the screen.
Where will you use it?
- Reading csv/excel data.
- Handling result tables.
- Building reports.
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-series-dataframe.pyand run it. - Change input values or sample data and observe the new output.
- Create one example related to reading CSV/Excel data.
- Write 5 lines explaining the logic in your own words.
Summary
Pandas Series and DataFrame 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 Series और DataFrame क्या है?
Pandas Series और DataFrame ka matlab hai: Pandas provides Series and DataFrame for handling tabular data like Excel sheets and CSV files. Simple words me, ye topic practical Python programs likhne me direct use hota hai.
Is topic ko sirf definition ke liye nahi, balki reading CSV/Excel data jaise real examples ke liye practice karein.
यह क्यों सीखना जरूरी है?
- Ye reading CSV/Excel data me kaam aata hai.
- Ye handling result tables se bhi connected hai.
- Isse aap code ka output aur errors better samajh paate hain.
Important Terms
| Term | Meaning |
|---|---|
| Series | One-dimensional labeled data structure in pandas. |
| DataFrame | Two-dimensional table structure in pandas. |
| columns | columns is an important term in this topic. |
| rows | rows is an important term in this topic. |
| head() | head() 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({
"Student": ["Aarav", "Riya", "Kabir"],
"Marks": [82, 94, 76]
})
print(df)
print("Average:", df["Marks"].mean())Complete Example Program
import pandas as pd
df = pd.DataFrame({
"Student": ["Aarav", "Riya", "Kabir"],
"Marks": [82, 94, 76]
})
print(df)
print("Average:", df["Marks"].mean())Expected Output
Program Explanation
import pandas as pdimports ready-made features from a module/library.df = pd.DataFrame({stores a value in df."Student": ["Aarav", "Riya", "Kabir"],performs the next step of the program logic."Marks": [82, 94, 76]performs the next step of the program logic.})performs the next step of the program logic.print(df)displays information or calculated result on the screen.print("Average:", df["Marks"].mean())displays information or calculated result on the screen.
Practical Uses
- Reading csv/excel data.
- Handling result tables.
- Building reports.
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-series-dataframe.pyfile me type karke run karein. - Values change karke output compare karein.
- reading CSV/Excel data par ek छोटा example banayen.
- Logic ko apne words me 5 lines me likhein.
सारांश
Pandas Series and DataFrame ko tab complete maanenge jab aap iska meaning, example, output aur practical use clearly explain kar saken.