Skip to content

Commit 44cbb09

Browse files
fix with older vintage
1 parent 3d3d644 commit 44cbb09

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

covid19dh/main.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ def covid19(country = None,
117117
write_src_cache(src, end, vintage)
118118
# cast columns
119119
df['date'] = df['date'].apply(lambda x: datetime.datetime.strptime(x, "%Y-%m-%d"))
120-
df['iso_numeric'] = df['iso_numeric'].apply(lambda x: float(x))
121-
120+
try: df['iso_numeric'] = df['iso_numeric'].apply(lambda x: float(x))
121+
except: pass
122+
122123
write_cache(df, level, end, raw, vintage)
123124

124125
# src
@@ -134,10 +135,19 @@ def covid19(country = None,
134135
# no idea why, but I found solution to mute it as follows
135136
with warnings.catch_warnings():
136137
warnings.simplefilter(action='ignore', category=FutureWarning)
137-
df = df[(df['iso_alpha_3'].isin(country)) |
138-
(df['iso_alpha_2'].isin(country)) |
139-
(df['iso_numeric'].isin(country)) |
140-
(df['administrative_area_level_1'].map(lambda s: s.upper()).isin(country)) ]
138+
139+
country_filter = df['administrative_area_level_1'].map(lambda s: s.upper()).isin(country)
140+
for feature in ["iso_alpha_2","iso_alpha_3","iso_numeric"]:
141+
try:
142+
country_filter = country_filter | df[feature].isin(country)
143+
except KeyError:
144+
pass
145+
df = df[country_filter]
146+
147+
#df = df[(df['iso_alpha_3'].isin(country)) |
148+
# (df['iso_alpha_2'].isin(country)) |
149+
# (df['iso_numeric'].isin(country)) |
150+
# (df['administrative_area_level_1'].map(lambda s: s.upper()).isin(country)) ]
141151
if start is not None:
142152
df = df[df['date'] >= start]
143153
if end is not None:
@@ -146,7 +156,7 @@ def covid19(country = None,
146156
# detect empty
147157
if df.empty:
148158
warnings.warn("no data for given settings", category=ResourceWarning)
149-
return None
159+
return None,None
150160
# sort
151161
df = df.sort_values(by=["id","date"])
152162

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setuptools.setup(
1414
name = 'covid19dh',
15-
version = '1.1.5',
15+
version = '1.2.0',
1616
author = 'Covid-19 Data Hub',
1717
author_email = 'martinbenes1996@gmail.com',
1818
description = 'Unified data hub for a better understanding of COVID-19 https://covid19datahub.io',
@@ -21,7 +21,7 @@
2121
packages=setuptools.find_packages(),
2222
license='GPL',
2323
url = 'https://www.covid19datahub.io/',
24-
download_url = 'https://github.com/covid19datahub/Python/archive/1.1.5.tar.gz',
24+
download_url = 'https://github.com/covid19datahub/Python/archive/1.2.0.tar.gz',
2525
keywords = ['2019-nCov', 'coronavirus', 'covid-19', 'covid-data', 'covid19-data'],
2626
install_requires=reqs,
2727
package_dir={'': '.'},

0 commit comments

Comments
 (0)