import pandas as pd
Homework 6
Advanced Group Oeprations
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.
Load the DataFrame for Part 1.
= 'https://bcdanl.github.io/data/climate_finance.csv'
path = pd.read_csv(path) climate_finance
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).
- Mitigation involves taking actions to reduce the emissions of greenhouse gases that are responsible for climate change.
- Adaptation involves taking actions to reduce the actual or expected damages from climate change (https://climate.nasa.gov/solutions/adaptation-mitigation).
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 regionProject/programme/activity
: Details in the climate change projectType 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.
= 'https://bcdanl.github.io/data/stock_2019_2024.csv'
path = pd.read_csv(path) stock
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 forDataFrameGroupBy
.
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 eachcompany
on eachDate
\(t\).- The formula for the Z-score of
Close
for eachcompany
onDate
\(t\) is as follows:
- The formula for the Z-score of
\[ 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 datet
; - \(\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 thestock
data to represent all the values ofOpen
,High
,Low
,Close
,Adj Close
, andVolume
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: