Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

On Jupyter Notebook complete the problems below: #Run this cell first before moving on import pandas as pd import matplotlib.pyplot as plt import seaborn as

On Jupyter Notebook complete the problems below:

#Run this cell first before moving on

import pandas as pd

import matplotlib.pyplot as plt

import seaborn as sns

plt.style.use("fivethirtyeight")

%matplotlib inline

#Use the urls to load the data

# url for covid cases:"https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_US.csv"

# url for covid deaths: "https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_US.csv"

df_cases = pd.read_csv()

df_deaths = pd.read_csv()

"""Problem 1"""

#Drop the following columns for df_cases and df_deaths. Use the inplace=True.

# "UID", "iso2", "iso3", "code3", "FIPS", "Country_Region", "Lat", "Long_"

"""Problem 2"""

#Rename the following columns:

# Admin2 to county, Province_State to state, Combined_key to county_state

"""Problem 3"""

#Melt/reshape df_cases. Make sure that var_name="dates" and value_name="cases"

#complete the melt function code below

df_cases_melted = pd.melt()

"""Problem 4"""

#Melt/reshape df_deaths. Make sure that var_name="dates" and value_name="deaths"

#complete the melt function code below

df_deaths_melted = pd.melt()

"""Problem 5"""

#Merge the melted dataframes for cases and deaths

#complete the merged function code below

df_merged = pd.merge()

df_merged.tail()

"""Problem 6"""

#Change the dates column to a datetime object

df_merged.dates = pd.to_datetime()

"""Problem 7"""

#Calculate the number of days into the outbreak for the US.

#The name the new column should be: us_outbreak

df_merged["us_outbreak"] =

"""Problem 8"""

#Run the cell

df = df_merged.groupby(["us_outbreak", "dates"], as_index=False)["cases"].sum()

"""Problem 8b"""

#Inspect df using the tail method

"""Problem 9"""

# perform a derived data column using the diff method on cases.

#The name the new column should be: new_cases

df["new_cases"] =

"""Problem 10"""

# Do a bar plot where the date is on the x-axis and new_cases on the y-axis.

#provide x/y axis labels and an appropriate chart title that explains visual.

#Rotate the x-axis ticks to 45.

"""Problem 11"""

# Do a derived data column using the pct_change method on new_cases.

#The name the new column should be: pct_new_cases

df["new_cases"] =

"""Problem 12"""

# Do a bar plot where date is on the x-axis and pct_new_cases on the y-axis.

#provide x/y axis labels and an appropriate chart title that explains visual.

#Rotate the x-axis ticks to 45.

"""Problem 13"""

#Use the following user-defined function on the new_cases column by using the apply method.

#The name the new column should be: tick

plt.figure(figsize=(10,6))

def tick_direction (x):

if x < 0:

return "up"

elif x > 0:

return "down"

else:

return "no change"

df["ticks"] =

"""Problem 14"""

# perform a value_counts method on the ticks column.

Thanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Explain the major phases in

Answered: 1 week ago