Ravindra BagaleCourses & study guides Track your progress

Guides

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:

  1. import pandas as pd
  2. dict of lists से DataFrame (या बाद में CSV)।
  3. df.head() — rows peek।
  4. df.info() — types और nulls।
  5. df["sales"] = Series।
  6. 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 DataFrame Two cities in loose lists.

Before — shop cities live in loose Python lists.

After DataFrame DataFrame of shop sales; sum 190.

After — one DataFrame; sales.sum() = 190.

Before: ढीली lists। After: एक DataFrame जिसका sales sum 190.

DataFrame क्यों?

  1. भरोसेमंद column names।
  2. कई rows एक जगह।
  3. 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

  1. Series — index वाली एक column: df["sales"]।
  2. DataFrame — कई columns: df।
  3. एक 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

  1. दो-row shop DataFrame।
  2. head, info, sum।
  3. Nashik 30 जोड़ो; sum 220.
  4. Markdown note: Series vs DataFrame।

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.