Answered step by step
Verified Expert Solution
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
pltstyle.useggplot
matplotlib inline
#Use the variablesurls to load the data
# url for covid cases:
covidcases https:githubcomCSSEGISandDataCOVIDrawmastercssecoviddatacssecovidtimeseriestimeseriescovidconfirmedUScsv
# url for covid deaths:
coviddeaths https:githubcomCSSEGISandDataCOVIDrawmastercssecoviddatacssecovidtimeseriestimeseriescoviddeathsUScsv
# It is okay to have a horizontal scroll bar for this cell.
dfcases pdreadcsvcovidcases
dfdeaths pdreadcsv # include coviddeaths variable in place of
#Run the cell, review the output, and move to the next cell
dfcases
#Run the cell, review the output, and move to the next cell
dfdeaths
Problem
# Run the cell, notice the additional data column in dfdeaths which will be remove in problem b
printCases DataFrame:", listdfcases.columns:
print # Do not modify this displays blank line for space between the Cases and Deaths output
printDeaths DataFrame:", listdfdeaths.columns:
Problem a
#Remove the following columns for dfcases using the drop method:
# "UID", "iso "iso "code "FIPS", "CountryRegion",
# "Lat", "Long
# Use the inplaceTrue.
dfcases.dropcolumns #remove and enter the columns names in the list, each as a string.
dfcases.head
Problem b
#Remove the same columns for dfdeaths but also include the extra data column in dfdeaths:
dfdeaths.drop #remove and enter code
dfdeaths.tail
Problem
#Rename the following columns for both dataframes using the rename method:
# Admin to county, ProvinceState to state, Combinedkey to countystate
printBefore rename:", listdfcases.columns # displays data column names for dfcases
dfcases.renamecolumns inplace
printAfter rename:", listdfcases.columns
print
printBefore rename:", listcolumns # displays data column names for dfdeaths
dfdeaths.rename
printlistdfdeaths. # displays data column names for dfdeaths
Problem
#Meltreshape dfcases. Columns to assign to
# the idvars parameter are: county, state, and countystate.
# Make sure that varname"dates" and valuename"cases"
#Complete the melt function code below.
dfcasesmelted pdmelt idvars varname valuename
dfcasesmelted.tail
Problem
#Meltreshape dfdeaths. Columns to assign to
# the idvars parameter are: county, state, and countystate.
#Make sure that varname"dates" and valuename"deaths"
#Complete the melt function code below.
dfdeathsmelted pdmelt
dfdeathsmelted.tail
Problem
#Merge the melted dataframes for cases and deaths.
#Complete the merged function code below.
dfmerged pdmerge
dfmerged.tail
Problem
#Using dfmerged, change data type for dates to a datetime object.
dfmerged.dates pdtodatetime
dfmerged.dtypes
Problem
#Calculate the number of days into the outbreak for each record.
#The name of the new column will be usoutbreak
dfmergedusoutbreak"
dfmergeddatesusoutbreak"iloc # this code outputs the number of days since the outbreak Day
#Run cell, review the dataframe output which include the new column usoutbreak
dfmerged
After completing problem run this cell and review the output.
Understand what the asindex parameter does.
df dfmerged.groupbyusoutbreak", "date" asindexFalsecasessum
dftail
Problem
#Using df from above, create a derived data column using the diff method on cases.
#The name of the new column is: newcases
dfnewcases"
dftail
Problem
#Use pltbar function to create a bar plot,
# have the dates on the xaxis and newcases on the yaxis.
#Provide x & y axis labels and an appropriate chart title that
# explains visual.
#Rotate the xaxis ticks to using the xticks function.
# Below are the functions used complete the code:
pltfigure # include figsize keyword argument
pltbar
pltxticks # include rotation keyword argument
pltxlabel
pltylabel
plttitle
plttightlayout
pltshow
Problem
# Provide the code that shows what the average number of
# newcases that were reported in
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started