Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'Province/State' #7

Open
adityacloud1 opened this issue Apr 14, 2020 · 9 comments
Open

KeyError: 'Province/State' #7

adityacloud1 opened this issue Apr 14, 2020 · 9 comments

Comments

@adityacloud1
Copy link

Respected Sir,
I tried to run yours filter for my dataset and getting following error while running #import pandas as pd confirmed=pd.merge(confirmed, population,how='left' ,on=['Province/State','Country']) death=pd.merge(death, population,how='left' ,on=['Province/State','Country']) recover=pd.merge(recover, population,how='left' ,on=['Province/State','Country']) confirmed.head()
error
Could, you please suggest me how to resolve this error

@Rank23
Copy link
Owner

Rank23 commented Apr 15, 2020

Try to run:
confirmed=pd.merge(confirmed, population,how='left' ,on=['Province/State','Country/Region'])
and make sure the 'population' df columns name are:
Province/State | Country/Region | Population

@adityacloud1
Copy link
Author

Thanks sir for yours kind response.

@adityacloud1
Copy link
Author

adityacloud1 commented Apr 23, 2020

Respected Sir,
When I tried to run following sub module, after execution it always gives error "division by zero" error. I tried for each input parameter eg. China, Japan, etc of Country/Region column.
`t['1_day_change']=t['3_day_change']=t['7_day_change']=t['1_day_change_rate']=t['3_day_change_rate']=t['7_day_change_rate']=t['last_day']=0
for i in range(1,len(t)):
if(t.iloc[i,1] is t.iloc[i-2,1]):
t.iloc[i,3]=t.iloc[i-1,2]-t.iloc[i-2,2]
t.iloc[i,6]=(t.iloc[i-1,2]/t.iloc[i-2,2]-1)*100
t.iloc[i,9]=t.iloc[i-1,2]
if(t.iloc[i,1] is t.iloc[i-4,1]):
t.iloc[i,4]=t.iloc[i-1,2]-t.iloc[i-4,2]
t.iloc[i,7]=(t.iloc[i-1,2]/t.iloc[i-4,2]-1)*100
if(t.iloc[i,1] is t.iloc[i-8,1]):
t.iloc[i,5]=t.iloc[i-1,2]-t.iloc[i-8,2]
t.iloc[i,8]=(t.iloc[i-1,2]/t.iloc[i-8,2]-1)*100
t=t.fillna(0)
t=t.merge(temp[['date','region', 'X']],how='left',on=['date','region'])
t=t.rename(columns = {'X':'kalman_prediction'})
t=t.replace([np.inf, -np.inf], 0)
t['kalman_prediction']=round(t['kalman_prediction'])
train=t.merge(confirmed[['region',' Population ']],how='left',on='region')
train=train.rename(columns = {' Population ':'population'})
train['population']=train['population'].str.replace(r" ", '')
train['population']=train['population'].str.replace(r",", '')
train['population']=train['population'].fillna(1)
train['population']=train['population'].astype('int32')
train['infected_rate'] =train['last_day']/train['population']*10000
train=train.merge(w,how='left',on=['date','region'])
train=train.sort_values(['region', 'date'])

division zero

@Rank23
Copy link
Owner

Rank23 commented Apr 24, 2020

You should check why you get zero values in t.iloc[,2].
If for some reason you get zeros, you can replace them with the actual values.

@adityacloud1
Copy link
Author

Dear Sir,
For the above issue the values of t.tail(7) are highlighted in the following screenshot:
t tail

Can you please share yours data set for Confirmed.csv, Deaths.csv and Recovered.csv.

@adityacloud1
Copy link
Author

Dear Sir,
I followed yours valuable suggestion and above errors were resolved.
However, for other different inputs like 'India,' 'Korea, South' the prediction output always gives NAN result. This is shown in the following screenshot
Kalam India
And for Korea, South
Kalam prediction south korea

@adityacloud1
Copy link
Author

Dear Sir,
Greeting of the Day !!
Please suggest solution for the above issue.

@Rank23
Copy link
Owner

Rank23 commented May 10, 2020

It seems like you don't get predictions from R script.
You can share your code with me and I'll try to assist.
rank23@gmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants