Programming, problem solving, and algorithms

CPSC 203, 2025 W1

October 7, 2025

Announcements

  • next week is a quiet week: no class meetings, no labs, no potw.

Today

Warm Up – datetime again

Exploring pandas:

  • Filtering Data
  • Making charts
  • Asking harder questions

Warm Up

datetime: a Python library that simplifies date computation.

Objects we need

  • date — a calendar day (year-month-day)
  • timedelta — a number of days you can add/subtract

Core calls

  • today=date.today(): today’s date
  • today.weekday(): an integer 0..6 with Mon=0, … , Sun=6
  • today - timedelta(days=k): the date k days earlier

Code

Data Frames

Some challenges…

Given last week’s chart:

  1. How many new songs were there?

  2. What’s the average peak?

  3. Among those who were on the list for more than 10wk, what’s the average peak? (Is it very different than the previous answer?)

  4. Which song changed the most? Was it rising or falling?

  5. Write and answer your own question:

    _____________________________________________________

Let’s Write Code

Open CA5.2 Billboard, and load class_nb.py.

PrairieLearn Activity

Some challenges…

Which song moved the most? Did it rise or fall?

C C C C C C
C C C C C C
C C C C C C
C C C C C C
C C C C C C
C C C C C C
C C C C C C
C C C C C C
C C C C C C
C C C C C C

Resources

https://pymotw.com/2/datetime/

https://www.dataschool.io/best-python-pandas-resources/

https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf

https://queirozf.com/entries/pandas-dataframe-plot-examples-with-matplotlib-pyplot