pandas DataFrame — Series vs DataFrame, head और info
Read this guide in: English · मराठी · हिंदी
Series एक labelled column है। DataFrame पूरी table है। pandas में DataFrame बनाओ या load करो, फिर fancy काम से पहले head() और info()। Tiny check: Mumbai 120 + Pune 70 = 190.
दोस्तों! Lists ठीक लगती हैं जब तक दस columns न आ जाएँ। आज Series vs DataFrame — shop sales table। छोटे वाक्य। असली numbers। समझा?
संक्षिप्त उत्तर
खड़ा starter path:
import pandas as pd- dict of lists से DataFrame (या बाद में CSV)।
df.head()— rows peek।df.info()— types और nulls।df["sales"]= Series।df["sales"].sum()— tiny example पर 190 confirm।
dict/lists → DataFrame → head → info → Series math
Language: English · मराठी · हिंदी
इस guide से पहले क्या चाहिए?
- Jupyter में Python + pandas।
- Python dict और list की पहचान।
- Course: Series and DataFrame.
Before और after
Before — shop cities live in loose Python lists.
After — one DataFrame; sales.sum() = 190.
Before: ढीली lists। After: एक DataFrame जिसका sales sum 190.
DataFrame क्यों?
- भरोसेमंद column names।
- कई rows एक जगह।
- Ready tools: filter, groupby, missing checks।
Shop exports, Instagram-like dumps, Infosys client sheets — सब tables। Interviewers head / info expect करते हैं।
Tiny shop DataFrame
import pandas as pd
df = pd.DataFrame({
"city": ["Mumbai", "Pune"],
"sales": [120, 70],
})
df.head()
दो rows, columns city और sales। pandas ने lists को table में wrap किया।
Series vs DataFrame
- Series — index वाली एक column:
df["sales"]। - DataFrame — कई columns:
df। - एक column → Series; दो → DataFrame।
s = df["sales"]
print(s.sum()) # 190
head, info, dtypes
हर नई table पर: head(), info(), dtypes, shape। गलत types, unexpected nulls, spaced names देखो।
Quick stats
df["sales"].sum() # 190
df["sales"].mean() # 95.0
df["sales"].max() # 120
Instagram-like उदाहरण
तीन posts: likes 80, 40, 70 → sum 190. बाद में groupby: Mumbai 120, Pune 70.
Common mistakes
| Mistake | Fix |
|---|---|
| import भूले | पहली cell में import pandas as pd |
weird names पर df.sales |
df["sales"] |
| बिना head shape trust | हमेशा head() |
| Series vs frame उलझन | एक column = Series याद रखो |
Ravindra Bagale's Tip
किसी भी chart से पहले head() और कागज़ पर जोड़ सकने वाला sum। 190 fail हो तो रुकें — table गलत है, IQ नहीं। समझा?
Practice task
- दो-row shop DataFrame।
- head, info, sum।
- Nashik 30 जोड़ो; sum 220.
- Markdown note: Series vs DataFrame।
Learn it properly
Related: read_csv / read_excel · Filter rows and columns
Samajla ka? Series = एक column। DataFrame = table। Drama से पहले head और info। 190 check रखो। अब आगे चलें।
Frequently asked questions
What is a Series?
A one-dimensional labelled array — usually one column of a DataFrame.
What is a DataFrame?
A two-dimensional table with labelled columns (and an index for rows).
Why head() before fancy plots?
You confirm columns and sample values before you trust any chart.
What does info() show?
Column names, non-null counts and data types — a fast health check.
Is the index the same as a column?
The index labels rows. You can reset_index later if you need it as a normal column.
Course links?
Chapter 5 Series and DataFrame lessons — linked at the end.