Skip to content

Commit

Permalink
fix: post county new_death nan error (#50)
Browse files Browse the repository at this point in the history
* fix: /post county new_death nan error

* fix: /post county new_death nan error
  • Loading branch information
leehanchung committed Apr 15, 2020
1 parent 979ff02 commit 729f1c6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/utils/county.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def read_county_stats(state: str, county: str) -> Dict:
# used data source 2 for new death number
deaths = deaths[deaths['Province_State'] == reverse_states_map[state]]
deaths = deaths[deaths['Admin2'] == county]
deaths = deaths.iloc[:, 12:].diff(axis=1).iloc[:, -1].values[0]
# 4/15/20: force cast into int before diff as pd sometimes read as
# float and throws nan.
deaths = deaths.iloc[:, 12:].astype('int32').\
diff(axis=1).iloc[:, -1].values[0]

df = df[df["state_name"] == reverse_states_map[state]]
# df = df.query(f"county_name == '{county}'")
Expand Down

0 comments on commit 729f1c6

Please sign in to comment.