Skip to content

Commit 8d14d35

Browse files
authored
211 Python dependencies (#221)
* upgrade pandas and matplotlib * added documentation * corrected typo
1 parent 8811131 commit 8d14d35

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

pycode/memilio-epidata/memilio/epidata/getCaseData.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def get_case_data(read_data=dd.defaultDict['read_data'],
182182
"dataframe is empty for csv and geojson!")
183183
# drop columns that do not exist in data from github
184184
df = df.drop(["Altersgruppe2", "Datenstand", "OBJECTID",
185-
"Bundesland", "Landkreis"], 1)
185+
"Bundesland", "Landkreis"], axis=1)
186186
df = df.convert_dtypes()
187187

188188
# output data to not always download it
@@ -237,7 +237,7 @@ def get_case_data(read_data=dd.defaultDict['read_data'],
237237

238238
# get rid of unnecessary columns
239239
df = df.drop(['NeuerFall', 'NeuerTodesfall', 'NeuGenesen',
240-
"IstErkrankungsbeginn", "Meldedatum", "Refdatum"], 1)
240+
"IstErkrankungsbeginn", "Meldedatum", "Refdatum"], axis=1)
241241

242242
print("Available columns:", df.columns)
243243

pycode/memilio-epidata/memilio/epidata/getCaseDatawithEstimations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def get_case_data_with_estimations(read_data=dd.defaultDict['read_data'],
143143
df_cases.loc[(df_cases[dstr] == date_jh), deaths_estimated] = np.round(
144144
fraction_deaths_conf * df_cases.loc[(df_cases[dstr] == date_jh), confirmed])
145145

146-
df_cases = df_cases.drop([dstr], 1)
146+
df_cases = df_cases.drop([dstr], axis=1)
147147
gd.write_dataframe(df_cases, data_path,
148148
file_to_change + "_estimated", file_format)
149149

pycode/memilio-epidata/memilio/epidata/getPopulationData.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def get_population_data(read_data=dd.defaultDict['read_data'],
286286
print('Information: Using new population data file ' + filename)
287287
df_pop_raw = gd.loadExcel(
288288
new_data_file, apiUrl='', extension='.xlsx',
289-
param_dict={"engine": None, "sheet_name": filename, "header": 4})
289+
param_dict={"engine": "openpyxl", "sheet_name": filename, "header": 4})
290290
column_names = list(df_pop_raw.columns)
291291
# rename columns
292292
rename_columns = {

pycode/memilio-epidata/memilio/epidata_test/test_epidata_getCaseData.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class TestGetCaseData(fake_filesystem_unittest.TestCase):
4343

4444
# load test data for read
4545
filename = os.path.join(here, 'test_epidata_getCaseData_data_read.json')
46-
file_object = open(filename, 'r')
4746
# Load JSON file data to a python dict object.
48-
dict_object = json.load(file_object)
47+
with open(filename, 'r') as file_object:
48+
dict_object = json.load(file_object)
4949
test_string_all_federal_states_and_counties_read = json.dumps(dict_object)[:-1] +\
5050
(""",{"Altersgruppe":"A60-A79","Geschlecht":"M","AnzahlFall":1,"AnzahlTodesfall":0,"Meldedatum":"2020-08-11",\
5151
"IdLandkreis":1002,"NeuerFall":0,"NeuerTodesfall":-9,"Refdatum":"2020-08-07","NeuGenesen":0,"AnzahlGenesen":1,\
@@ -109,9 +109,9 @@ class TestGetCaseData(fake_filesystem_unittest.TestCase):
109109
# (https://github.com/robert-koch-institut/SARS-CoV-2_Infektionen_in_Deutschland)
110110
filename = os.path.join(
111111
here, 'test_epidata_getCaseData_data_github.json')
112-
file_object = open(filename, 'r')
113112
# Load JSON file data to a python dict object.
114-
dict_object_github = json.load(file_object)
113+
with open(filename, 'r') as file_object:
114+
dict_object_github = json.load(file_object)
115115

116116
test_string_all_federal_states_and_counties_github = json.dumps(
117117
dict_object_github)[:-1] + ("""]""")
@@ -120,9 +120,9 @@ class TestGetCaseData(fake_filesystem_unittest.TestCase):
120120
# (https://npgeo-corona-npgeo-de.hub.arcgis.com/datasets/66876b81065340a4a48710b062319336/about)
121121
filename = os.path.join(
122122
here, 'test_epidata_getCaseData_data_arcgis.json')
123-
file_object = open(filename, 'r')
124123
# Load JSON file data to a python dict object.
125-
dict_object_arcgis = json.load(file_object)
124+
with open(filename, 'r') as file_object:
125+
dict_object_arcgis = json.load(file_object)
126126

127127
test_string_all_federal_states_and_counties_arcgis = json.dumps(
128128
dict_object_arcgis)[:-1] + ("""]""")

pycode/memilio-epidata/setup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ def run(self):
6868
long_description='',
6969
test_suite='memilio.epidata_test',
7070
install_requires=[
71-
'pandas<1.2.0',
72-
'matplotlib<3.4',
71+
# smaller pandas versions contain a bug that sometimes prevents reading
72+
# some excel files (e.g. population or twitter data)
73+
'pandas>=1.2.2',
74+
'matplotlib',
7375
'tables',
74-
'numpy>=1.21',
76+
'numpy>=1.21', # smaller numpy versions cause a security issue
7577
'openpyxl',
7678
'xlrd',
7779
'requests',
@@ -80,7 +82,8 @@ def run(self):
8082
],
8183
extras_require={
8284
'dev': [
83-
'pyfakefs==4.1.0',
85+
# smaller pyfakefs versions use deprecated functions for matplotlib versions >=3.4
86+
'pyfakefs>=4.2.1',
8487
'freezegun',
8588
'coverage',
8689
'pylint<=2.11.1',

0 commit comments

Comments
 (0)