Ravindra BagaleCourses & study guides

5. pandas DataFrames and Series

5.1 Series and DataFrame

In short: A DataFrame is a table of aligned Series (columns).

A Series is one column with an index. A DataFrame is a table of aligned Series (columns).

import pandas as pd

s = pd.Series([64, 90, 240], index=["BLK-001", "BLK-002", "BLK-003"], name="amount")
print(s)
print(s.mean())
df = pd.DataFrame({
    "order_id": ["BLK-260314-001", "BLK-260314-002", "AMN-260314-004"],
    "city": ["Pune", "Nashik", "Kolhapur"],
    "product": ["Gokul Cow Milk 500 ml", "Nashik Grapes 500 g", "Amul Butter 100 g"],
    "qty": [2, 1, 1],
    "amount": [64, 90, 58],
    "status": ["Delivered", "Delivered", "Cancelled"],
    "customer": ["Ruhi Bagale", "Amir", "Zoya"],
})
df