Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Exercises

Exercise 1: Creating Household IDs

Topic: np.arange

Description: Create a simple list of numbers to serve as ID tags.

Task: Create a list of 10 sequential Household IDs starting from 1 to 10 using np.arange.

Exercise 2: Total Population Calculation

Topic: Adding Arrays

Description: Add two lists of numbers together effectively.

Task: You have the counts of Males and Females for 5 different barangays. Add them together to get the Total Population for each barangay.

  • Males: [100, 150, 120, 130, 110]

  • Females: [110, 140, 130, 120, 115]

Exercise 3: Finding the Highest Inflation Rate

Topic: np.max

Description: Find the largest number in a list.

Task: Given a list of inflation rates from different months, identify the highest rate recorded using np.max.

  • Rates: [3.4, 4.2, 5.1, 8.7, 6.1, 4.5]

Exercise 4: Select the First Region

Topic: Indexing (Selecting items)

Description: Pick a specific item from a list using its position.

Task: You have a list of population counts. Select and print only the first number in the list (index 0).

  • Populations: [5000, 2000, 3000, 8000]

Exercise 5: Filter Large Households

Topic: Filtering (Boolean Indexing)

Description: Find numbers that are bigger than a specific value.

Task: You have a list of household family sizes. Find and print only the family sizes that have more than 5 members.

  • Family Sizes: [3, 4, 8, 2, 6, 10, 4]

Long Exercise: Annual Report on Violence Against Women (VAW)

Scenario: You are preparing a report on the Monthly Reported Cases of Violence Against Women (VAW) in a specific municipality for the year 2024.

Your Tasks:

  1. Create the Data: Convert the list of 12 months into a NumPy array.

  2. Total Annual Cases: Calculate the total number of VAW cases reported for the whole year.

  3. Average Monthly Cases: Calculate the average number of cases reported per month.

  4. Peak Incident Month: Identify the highest number of cases recorded in a single month.

  5. Identify High-Risk Months: Find and print all months where the reported cases were greater than 20 (indicating a surge).

Raw Data (Jan-Dec): 15, 18, 12, 14, 25, 28, 10, 8, 30, 22, 15, 19

Exercises for Dataframes in marimo

Fertilizer Use and Crop Response Analysis

  1. 99.1_additional_exercises_01.py

    • Python basics

    • NumPy

    • Pandas

    • Loops

    • Groupby, filtering, lambda functions

    • Basic data visualization

Labor Productivity Analysis

  1. 99.1_additional_exercises_02.py

    • Perform computations

    • Filter and classification

    • Loop through averages

    • Use lambda functions

    • Visualize data

Farm Typology and Survey Prioritization

  1. 99.1_additional_exercises_dataframes.py

    • Dive into DataFrames