Created
March 24, 2020 00:22
-
-
Save mcdan/765936e9a760245dd496aff8a3950aa5 to your computer and use it in GitHub Desktop.
Covid Percents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import pandas as pd | |
import os | |
notebook_path = os.path.abspath(".") | |
covidDataJSON = requests.request("GET", "https://covidtracking.com/api/states") | |
df_covid = pd.read_json(covidDataJSON.text) | |
df_covid["percent_pos"] = (df_covid["positive"] / df_covid["total"]) *100 | |
df_covid.sort_values("percent_pos", ascending=False).filter(items=["state", "percent_pos"]) | |
df_covid_rest_of_country = df_covid.loc[df_covid['state'] != "NY"] | |
totals = df_covid_rest_of_country.filter(items=["positive", "total"]).sum() | |
print("US Total excluding NY state", (totals["positive"] / totals["total"]) *100) | |
df_new_york= df_covid.loc[df_covid['state'] == "NY"] | |
print("NY", df_new_york["percent_pos"].sum()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state percent_pos | |
55 VI 100.000000 ( throw this out of % top as they are only reporting positve cases) | |
31 NJ 86.260237 | |
35 OH 75.945017 | |
20 MD 75.392670 | |
8 DE 65.384615 | |
3 AZ 45.689655 | |
22 MI 39.093318 | |
24 MO 33.152174 | |
34 NY 26.664027 | |
18 LA 19.704102 | |
25 MS 17.887931 | |
40 SC 16.940510 | |
16 KS 16.432866 | |
2 AR 16.111111 | |
42 TN 15.821971 | |
53 GU 15.263158 | |
10 GA 15.229828 | |
15 IN 13.214286 | |
14 IL 13.021889 | |
29 NE 12.315271 | |
51 PR 12.156863 | |
5 CO 10.871965 | |
7 DC 9.438568 | |
36 OK 9.236032 | |
6 CT 9.222222 | |
1 AL 9.115721 | |
9 FL 8.943027 | |
38 PA 8.896256 | |
19 MA 8.708810 | |
39 RI 8.452951 | |
45 VA 6.870435 | |
4 CA 6.564394 | |
33 NV 6.559572 | |
47 WA 6.464777 | |
46 VT 6.350550 | |
17 KY 5.573419 | |
48 WI 5.571926 | |
44 UT 5.092134 | |
37 OR 4.973958 | |
23 MN 4.951538 | |
12 IA 4.888268 | |
50 WY 4.207120 | |
21 ME 3.692202 | |
27 NC 3.519791 | |
43 TX 3.500746 | |
13 ID 3.466077 | |
49 WV 3.448276 | |
30 NH 3.331909 | |
26 MT 2.881356 | |
41 SD 2.654028 | |
0 AK 2.272727 | |
28 ND 2.169197 | |
11 HI 1.859847 | |
32 NM 1.206833 | |
52 AS NaN | |
54 MP NaN | |
US Total excluding NY state 9.866661723062377 | |
NY 26.66402687478445 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment