+91 81900 98289

Pandas Tutorial

This Pandas Tutorial lesson is for a beginner. Read the short notes, run each example, then change one name or number and run it again.

Pandas is the usual tool for tables of rows and columns. A DataFrame is that table, and a Series is one column.

The runner here has no Pandas. A list of dicts shows the same filter you would write with a column comparison.

Example 1: Start here

Locally, read a sheet with pandas.read_csv and filter with df[df["score"] >= 80].

rows = [{"name": "Meera", "score": 82}, {"name": "Arun", "score": 74}] # a list; the values stay in this order print([row["name"] for row in rows if row["score"] >= 80]) # keep the items that pass the test

Example 2: Read one column

Pandas Tutorial treats a table as rows. This prints only the name column.

rows = [{"name": "Meera", "score": 36}, {"name": "Arun", "score": 74}] # a list; the values stay in this order print([row["name"] for row in rows]) # in is True when the value is found

Example 3: Filter the table

A filter keeps the rows that pass a test. Meera stays when her score is at least 80.

rows = [{"name": "Meera", "score": 36}, {"name": "Arun", "score": 74}] # a list; the values stay in this order print([row["name"] for row in rows if row["score"] >= 80]) # keep the items that pass the test

Example 4: Add a column

A new column is just a new key. passed is True when the score is high enough.

row = {"name": "Meera", "score": 36} # a dictionary; each key has one value row["passed"] = row["score"] >= 80 # change this one field print(row)
Locally, read a sheet with pandas.read_csv and filter with df[df["score"] >= 80].
Call Now 81900 98289