Ravindra BagaleCourses & study guides Track your progress

Guides

pandas DataFrame for Beginners — Series vs DataFrame, head and info

Read this guide in: English · मराठी · हिंदी

A Series is one labelled column. A DataFrame is a full table. In pandas you build or load a DataFrame, then use head() and info() before any fancy work. Tiny check: Mumbai 120 + Pune 70 = 190.

Chala mitrano! Lists feel fine until you have ten columns. Today Series vs DataFrame with a shop sales table. Short sentences. Real numbers. Samajla ka?

Quick answer

Vertical starter path:

  1. import pandas as pd
  2. Build a DataFrame from a dict of lists (or read a CSV later).
  3. df.head() — peek at rows.
  4. df.info() — types and nulls.
  5. df["sales"] is a Series.
  6. df["sales"].sum() — confirm 190 on the tiny example.
dict/lists → DataFrame → head → info → Series math

Language: English · मराठी · हिंदी

What do I need before this guide?

  • Python + pandas in a Jupyter notebook (see the install guide).
  • Comfort with a Python dict and list.
  • Course: Series and DataFrame.

Before and after (look at the tables first)

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: loose lists. After: one DataFrame whose sales sum to 190.

Why DataFrame (not only lists)?

What a DataFrame gives you

  1. Column names you can trust.
  2. One place for many rows.
  3. Ready tools: filter, groupby, missing-value checks.

Why you care

  1. Shop exports, Instagram-like engagement dumps and Infosys client sheets all arrive as tables.
  2. Interviewers expect head / info muscle memory.

Build a tiny shop DataFrame

import pandas as pd

df = pd.DataFrame({
    "city": ["Mumbai", "Pune"],
    "sales": [120, 70],
})
df.head()

What you see:

  1. Two rows.
  2. Columns city and sales.
  3. A default index 0, 1.

What it means: pandas wrapped your lists into a table.

Series vs DataFrame (plain words)

  1. Series — one column with an index. Example: df["sales"].
  2. DataFrame — several columns side by side. Example: df.
  3. Selecting one column returns a Series; selecting two returns a DataFrame.
s = df["sales"]          # Series
both = df[["city", "sales"]]  # DataFrame
print(s.sum())           # 190

head, info, dtypes

Vertical checks every time you meet a new table:

  1. df.head() — first rows (default 5).
  2. df.head(2) — only two rows on tiny data.
  3. df.info() — row count, nulls, dtypes.
  4. df.dtypes — types only.
  5. df.shape — (rows, columns).

Course: head, info, dtypes.

What you look for

  1. Wrong types (sales as text).
  2. Unexpected null counts.
  3. Surprising column names with spaces.

Columns as Series — quick stats

df["sales"].sum()    # 190
df["sales"].mean()   # 95.0
df["sales"].max()    # 120

Course: Columns as Series — quick stats.

Instagram-like mini example

Suppose engagement:

post_id city likes
1 Mumbai 80
2 Mumbai 40
3 Pune 70
  1. DataFrame holds all three posts.
  2. df["likes"].sum() → 190.
  3. Later groupby will split Mumbai 120 vs Pune 70.

Common beginner mistakes

Mistake What happens Fix
Forget import pandas as pd NameError Import first cell
df.sales with weird column names Awkward / fails Prefer df["sales"]
Trust shape without head Silent wrong file Always head()
Edit a Series and expect magic Confusion Know Series vs frame

Ravindra Bagale's Tip

Before any chart, print head() and one sum you can re-add on paper. If 190 fails, stop — the table is wrong, not your IQ. Samajla ka?

Practice task

In Jupyter:

  1. Build the two-row shop DataFrame above.
  2. Print head(), info(), and sales sum.
  3. Add a third city Nashik with sales 30; new sum should be 220.
  4. Write one Markdown note: “Series = likes column; DataFrame = full posts table.”

Samajla ka? Series = one column. DataFrame = table. head and info before drama. Keep the 190 check. Aata pudhe jaauya.

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.