Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#Run this cell first before moving on import pandas as pd import matplotlib.pyplot as plt import seaborn as sns plt . style.use ( ggplot

#Run this cell first before moving on
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use("ggplot")
%matplotlib inline
#Use the variables/urls to load the data
# url for covid cases:
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:
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"
# It is okay to have a horizontal scroll bar for this cell.
df_cases = pd.read_csv(covid_cases)
df_deaths = pd.read_csv(---) # include covid_deaths variable in place of ---
#Run the cell, review the output, and move to the next cell
df_cases
#Run the cell, review the output, and move to the next cell
df_deaths
"""Problem 0"""
# Run the cell, notice the additional data column in df_deaths which will be remove in problem 1b.
print("Cases DataFrame:", list(df_cases.columns[0:12]))
print("") # Do not modify - this displays blank line for space between the Cases and Deaths output
print("Deaths DataFrame:", list(df_deaths.columns[0:13]))
"""Problem 1a"""
#Remove the following columns for df_cases using the drop method:
# "UID", "iso2", "iso3", "code3", "FIPS", "Country_Region",
# "Lat", "Long_"
# Use the inplace=True.
df_cases.drop(columns=[---]) #remove --- and enter the columns names in the list, each as a string.
df_cases.head()
"""Problem 1b"""
#Remove the same columns for df_deaths but also include the extra data column in df_deaths:
df_deaths.drop(---) #remove --- and enter code
df_deaths.tail(3)
"""Problem 2"""
#Rename the following columns for both dataframes using the rename method:
# Admin2 to county, Province_State to state, Combined_key to county_state
print("Before rename:", list(df_cases.columns)) # displays data column names for df_cases
df_cases.rename(columns={---}, inplace=---)
print("After rename:", list(df_cases.columns))
print("")
print("Before rename:", list(---.columns)) # displays data column names for df_deaths
df_deaths.rename(---,---)
print(list(df_deaths.---)) # displays data column names for df_deaths
"""Problem 3"""
#Melt/reshape df_cases. Columns to assign to
# the id_vars parameter are: county, state, and county_state.
# Make sure that var_name="dates" and value_name="cases"
#Complete the melt function code below.
df_cases_melted = pd.melt(---, id_vars=[---], var_name=---, value_name=---)
df_cases_melted.tail(3)
"""Problem 4"""
#Melt/reshape df_deaths. Columns to assign to
# the id_vars parameter are: county, state, and county_state.
#Make sure that var_name="dates" and value_name="deaths"
#Complete the melt function code below.
df_deaths_melted = pd.melt(---)
df_deaths_melted.tail(3)
"""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"""
#Using df_merged, change data type for dates to a datetime object.
df_merged.dates = pd.to_datetime(---)
df_merged.dtypes
"""Problem 7"""
#Calculate the number of days into the outbreak for each record.
#The name of the new column will be us_outbreak
df_merged["us_outbreak"]=---
df_merged[["dates","us_outbreak"]].iloc[-1] # this code outputs the number of days since the outbreak (Day 0)
#Run cell, review the dataframe output which include the new column (us_outbreak)
df_merged
"""
After completing problem 7, run this cell and review the output.
Understand what the as_index parameter does.
"""
df = df_merged.groupby(["us_outbreak", "date"], as_index=False)["cases"].sum()
df.tail()
"""Problem 8"""
#Using df from above, create a derived data column using the diff method on cases.
#The name of the new column is: new_cases
df["new_cases"]=---
df.tail()
""" Problem 9"""
#Use plt.bar() function to create a bar plot,
# have the dates 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 using the xticks function.
# Below are the functions used - complete the code:
plt.figure(---) # include figsize keyword argument
plt.bar(---)
plt.xticks(---) # include rotation keyword argument
plt.xlabel(---)
plt.ylabel(---)
plt.title(---)
plt.tight_layout()
plt.show()
""" Problem 10"""
# Provide the code that shows what the average number of
# new_cases that were reported in 2021
Please help me solve the problems above please. I need to fill in the ---. Please use Jupyter notebook to solve these problems please

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

How is a transaction loss different from an annual loss?

Answered: 1 week ago

Question

Write an elaborate note on marketing environment.

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago