Homework 6

Advanced Group Oeprations

Author

Byeong-Hak Choe

Published

March 12, 2024

Modified

March 17, 2024

Direction

  • Please submit your Jupyter Notebook for Homework 6 to the Brightspace with the name below:

    • danl-m1-hw6-LASTNAME-FIRSTNAME.ipynb
      ( e.g., danl-m1-hw6-choe-byeonghak.ipynb )
  • The due is March 19, 2024, 7:00 P.M.

  • Please send Byeong-Hak an email (bchoe@geneseo.edu) if you have any questions.

  • Please prepare a Jupyter/Python Notebook (*.ipynb) to address all questions.

  • Make at least some simple comment (# ...) in each question.

  • Make one text cell to explain things in each question.

  • Import Python libraries you need here.

import pandas as pd






Load the DataFrame for Part 1.

path = 'https://bcdanl.github.io/data/climate_finance.csv'
climate_finance = pd.read_csv(path)
  • Climate finance refers to local, national or transnational financing—drawn from public, private and alternative sources of financing—that seeks to support mitigation and adaptation actions that will address climate change (https://unfccc.int/topics/introduction-to-climate-finance).

  • A unit of observation in climate_finance DataFrame is a climate change project.


Variable Description

  • Party: a party (country) that provides a funding contribution to recipient country/region for their cliamte change project.

  • Recipient country/region: Recipient country or region

  • Project/programme/activity: Details in the climate change project

  • Type of support:

    • adaptation if the climate change project is related to adaptation project.
    • mitigation if the climate change project is related to mitigation project.
  • Year: Year that funding contribution is committed or provided.

  • Contribution: An amount of funding contribution for the climate change project (in USD).

  • Status:

    • committed if a party commits to providing the funding contribution for the climate change project, but the funding contribution is NOT actually provided.
    • provided if the funding contribution was provided for the climate change project.
  • Energy:

    • TRUE if the project is energy-related;
    • FALSE otherwise.


Question 1

For each party, calculate the total funding contributions that were disbursed or provided for mitigation projects for each year.

Answer:



Question 2

How many parties have provided positive funding contributions to other countries or regions for their adaptation projects for every single year from 2011 to 2018?

Answer:



Part 2



Consider the stock DataFrame for Part 2.

path = 'https://bcdanl.github.io/data/stock_2019_2024.csv'
stock = pd.read_csv(path)

Question 3

What are the minimum, first quartile, median, thrid quartile, maximum, mean, and standard deviation of Close and Volume for each company?

  • Hint: describe() is available for DataFrameGroupBy.

Answer:


Question 4

Find the 10 largest values for Volume for each company using a lambda function.

Answer:


Question 5

  • Calculate the Z-score of Close for each company on each Date \(t\).
    • The formula for the Z-score of Close for each company on Date \(t\) is as follows:

\[ z_{t} = \frac{\text{Close}_{t} - \text{mean}(\text{Close}_{t})}{\text{std}(\text{Close}_{t})}, \]

where

  • \(\text{Close}_{t}\) is a company’s Close price on date t;
  • \(\text{mean}(\text{Close}_{t})\) is the mean value of Close for a company;
  • \(\text{std}(\text{Close}_{t})\) is the standard deviation of Close for a company.

Answer:


Question 6

  • Use the transform() method on the stock data to represent all the values of Open, High, Low, Close, Adj Close, and Volume in terms of the first date in the data.

  • To do so, divide all values for each company by the values of the first date in the data for that company.

Answer:




Back to top