Aug-20-2021, 07:13 PM
import datetime #!/usr/bin/env python __author__ = "Michael Brown" __license__ = "Based off of sript by Sreenivas Bhattiprolu of Python for Microscopists" import pandas as pd import datetime as dt from matplotlib import pyplot as plt import seaborn as sns import os USAPopulation=328239523 #Pulling Data Frame USACOVID=pd.read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-states.csv") #Formatting Date USACOVID['date'] = [dt.datetime.strptime(x,'%Y-%m-%d') for x in USACOVID['date']] states=['Maryland'] CVD_MD = USACOVID[USACOVID.state.isin(states)] #Create subset data frame for select countries CVD_MD['CasesDaily'] = CVD_MD['cases'].diff() print (CVD_MD.dtypes) print(CVD_MD.tail())The warning message that I am getting is as follows:
Error:<ipython-input-3-33bb49eef431-NL5PxVOdetPVzV6OQYA2jG>:26: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
CVD_MD['CasesDaily'] = CVD_MD['cases'].diff()
Is this because I am using one data frame and then pulling it into a different (new) data frame?