Classwork 15

Pandas Fundamental V-1: Reshaping DataFrames

Author

Byeong-Hak Choe

Published

April 20, 2026

Modified

April 17, 2026

import pandas as pd 
import numpy as np

# Below is for an interactive display of DataFrame in Colab
from google.colab import data_table
data_table.enable_dataframe_formatter()

Question 1. Persoanl Income in New York State

ny_pincp = pd.read_csv('https://bcdanl.github.io/data/NY_pinc_wide.csv')

The following is the ny_pincp DataFrame:


  • Reshape ny_pincp to a longer format.
    • Make sure the resulting DataFrame has county-year as the unit of observation.
    • New York county FIPS code:
      • A 5-digit geographic identifier for a county in New York State.
      • The first 2 digits are the state FIPS code for New York (36).
      • The last 3 digits identify the county within New York.
      • Example:
        • 36001 = Albany County
        • 36055 = Monroe County
        • 36063 = Niagara County

Answer:


Question 2. COVID-19 Cases

covid = pd.read_csv('https://bcdanl.github.io/data/covid19_cases.csv')

The following is the covid DataFrame:


  • Create a wide-form data frame from covid in which:
    • variable names come from countriesAndTerritories, and
    • values come from cases.


Answer:




Discussion

Welcome to our Classwork 15 Discussion Board! ๐Ÿ‘‹

This space is designed for you to engage with your classmates about the material covered in Classwork 15.

Whether you are looking to delve deeper into the content, share insights, or have questions about the content, this is the perfect place for you.

If you have any specific questions for Byeong-Hak (@bcdanl) regarding the Classwork 15 materials or need clarification on any points, donโ€™t hesitate to ask here.

All comments will be stored here.

Letโ€™s collaborate and learn from each other!

Back to top