Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 29, 2020 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/8afd50c64dac57932feb93331995fe51 to your computer and use it in GitHub Desktop.
Save amankharwal/8afd50c64dac57932feb93331995fe51 to your computer and use it in GitHub Desktop.
world = pd.DataFrame({"Country":[],"Cases":[]})
world["Country"] = df0.iloc[:,1:].columns
cases = []
for i in world["Country"]:
cases.append(pd.to_numeric(df0[i][1:]).sum())
world["Cases"]=cases
country_list=list(world["Country"].values)
idx = 0
for i in country_list:
sayac = 0
for j in i:
if j==".":
i = i[:sayac]
country_list[idx]=i
elif j=="(":
i = i[:sayac-1]
country_list[idx]=i
else:
sayac += 1
idx += 1
world["Country"]=country_list
world = world.groupby("Country")["Cases"].sum().reset_index()
world.head()
continent=pd.read_csv("continents2.csv")
continent["name"]=continent["name"].str.upper()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment