Python/🐼 Pandas for Data Analysis/DataFrames Basics

DataFrames Basics

A DataFrame is a 2D labeled data structure. Create from dicts, lists, or CSV files. Access columns with df["col"] or df.col.

Guided Example

import pandas as pd

data = {"name": ["Alice", "Bob"], "age": [30, 25]}
df = pd.DataFrame(data)
print(df)
print(df["name"])

Practice Problems (0/3 solved)

Easy

Create a DataFrame

Create a DataFrame with columns "product" and "price" containing: Apple/1.5, Banana/0.5, Cherry/3.0. Print the DataFrame.

Loading Python...
Loading...

Loading Python runtime (Pyodide)...

Easy

Select and Filter

Given a DataFrame with products and prices, print only products with price > 1.0.

Loading Python...
Loading...

Loading Python runtime (Pyodide)...

Medium

Add Calculated Column

Add a "tax" column (10% of price) and a "total" column (price + tax). Print the DataFrame.

Loading Python...
Loading...

Loading Python runtime (Pyodide)...