Thuta Learning
ExercisesData & Databasesintermediate

Exercises: Series & DataFrame Warm-up

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Practice the material from Series & DataFrame Warm-up hands-on
  • Reinforce the skills you've already learned through practice
  • Get comfortable finding bugs, fixing them, and checking your own work

Quick Think

This lesson isn't new teaching content — it's a set of self-practice tasks covering what you learned in the Series, DataFrame, reading-data, inspecting-data, and selection lessons. You'll create both data structures yourself and get hands-on practice selecting columns and rows. Since this is beginner level, the goal isn't to memorize syntax but to build understanding of the logic through experimentation. We recommend opening a code editor and actually running each task.

Exercises

Task 1: Create a Pandas Series from a Python list, then set custom index labels using student names. Task 2: Create a DataFrame from dictionary data (3 columns — Name, Age, City — and 4 rows), then print .head(), .info(), and .shape. Task 3: From the DataFrame above, pull out the Name column alone as a Series, then pull out the Name and City columns together as a DataFrame (pay attention to how double brackets [[ ]] are used). Task 4 (optional): Use .loc[] to get row index 1 and .iloc[] to get row position 0, then compare what's different about the results.

Code Example

python
import pandas as pd

# Task 1: Series with custom index
scores = [88, 92, 79]
# TODO: pd.Series(scores, index=["Aye", "Bo", "Cho"]) ဆောက်ပါ


# Task 2: DataFrame from dictionary
data = {
    "Name": ["Aye", "Bo", "Cho", "Dee"],
    "Age": [21, 23, 22, 24],
    "City": ["Yangon", "Mandalay", "Yangon", "Bago"]
}
df = pd.DataFrame(data)
# TODO: df.head(), df.info(), df.shape ကို print လုပ်ပါ


# Task 3: column selection
# TODO: name_series = df["Name"]
# TODO: subset_df = df[["Name", "City"]]


# Task 4 (optional): loc vs iloc
# TODO: df.loc[1]
# TODO: df.iloc[0]
You should see
You'll be able to create Series data and DataFrame data distinctly, and correctly select both a single column and multiple columns, producing the expected output.

5-Minute Try

In 5 minutes, write out Task 1 and Task 2 in your code editor and run them — pay close attention to the Dtype column in the .info() output.

A Quick Warning

Don't panic if you hit an error while working through these tasks — read the full error message and check your column names and bracket count, and most of the time you'll spot the fix right away.

Easy traps

  • It's easy to confuse df["Name"] (returns a Series) with df[["Name"]] (returns a DataFrame) — a single bracket versus double brackets completely changes the return type
  • People sometimes accidentally use .loc[] as if it worked by position, like .iloc[], instead of by index label

Try It Yourself Now

In 5 minutes, write out Task 1 and Task 2 in your code editor and run them — pay close attention to the Dtype column in the .info() output.

You'll know it worked when: You'll be able to create Series data and DataFrame data distinctly, and correctly select both a single column and multiple columns, producing the expected output.

Exercises: Series & DataFrame Warm-up | Thuta Learning