Skip to content

Commit dea4f61

Browse files
More specific function naming.
1 parent 9b4ac3b commit dea4f61

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

src/project_mbb/data_management/clean_enusc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def clean_enusc(raw_enusc):
2121
enusc_category = _map_categories(enusc_renamed)
2222
# here check for no objects present
2323
enusc_filled = _fill_missing(enusc_category)
24-
enusc_dtypes = _set_data_types(enusc_filled)
24+
enusc_dtypes = _set_data_types_not_mapped_var(enusc_filled)
2525
return enusc_dtypes
2626

2727

@@ -82,7 +82,7 @@ def _fill_missing(enusc_mapped):
8282
return enusc_filled
8383

8484

85-
def _set_data_types(enusc_filled):
85+
def _set_data_types_not_mapped_var(enusc_filled):
8686
for value in floats:
8787
enusc_filled[value] = enusc_filled[value].astype(pd.Float64Dtype())
8888
for var in integers:

tests/data_management/test_data_mgt_enusc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
_filter_enusc,
88
_map_categories,
99
_rename_enusc,
10-
_set_data_types,
10+
_set_data_types_not_mapped_var,
1111
)
1212
from project_mbb.parameters import (
1313
categories,
@@ -163,13 +163,13 @@ def test_amount_of_missing(enusc_raw_short):
163163
+ [(val, pd.CategoricalDtype()) for val in categories]
164164
+ [(ent, "object") for ent in strings],
165165
)
166-
def test_set_data_types(enusc_raw_short, column, expected_dtype):
166+
def test_set_data_types_not_mapped_var(enusc_raw_short, column, expected_dtype):
167167
errors = []
168168
enusc_filtered = _filter_enusc(enusc_raw_short, relevant_var)
169169
enusc_renamed = _rename_enusc(enusc_filtered, rename_mapping)
170170
enusc_category = _map_categories(enusc_renamed)
171171
enusc_filled = _fill_missing(enusc_category)
172-
enusc_dtypes = _set_data_types(enusc_filled)
172+
enusc_dtypes = _set_data_types_not_mapped_var(enusc_filled)
173173

174174
if isinstance(expected_dtype, pd.CategoricalDtype):
175175
if not isinstance(enusc_dtypes[column].dtype, pd.CategoricalDtype):
@@ -195,15 +195,15 @@ def test_set_data_types(enusc_raw_short, column, expected_dtype):
195195
+ [(val, pd.Float64Dtype()) for val in categories]
196196
+ [(ent, "thing") for ent in strings],
197197
)
198-
def test_fail_set_data_types_for_check_testing(
198+
def test_fail_set_data_types_not_mapped_var(
199199
enusc_raw_short, column, wrong_expected_dtype
200200
):
201201
errors = []
202202
enusc_filtered = _filter_enusc(enusc_raw_short, relevant_var)
203203
enusc_renamed = _rename_enusc(enusc_filtered, rename_mapping)
204204
enusc_category = _map_categories(enusc_renamed)
205205
enusc_filled = _fill_missing(enusc_category)
206-
enusc_dtypes = _set_data_types(enusc_filled)
206+
enusc_dtypes = _set_data_types_not_mapped_var(enusc_filled)
207207

208208
if isinstance(wrong_expected_dtype, pd.CategoricalDtype):
209209
if not isinstance(enusc_dtypes[column].dtype, pd.CategoricalDtype):

work_maren/tests_maren.ipynb

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -98975,7 +98975,7 @@
9897598975
" enusc_category = _map_category_region(enusc_filtered)\n",
9897698976
" enusc_renamed = _rename_enusc(enusc_filtered)\n",
9897798977
" enusc_notna = _fill_missings(enusc_renamed)\n",
98978-
" enusc_dtypes = _set_data_types(enusc_notna)\n",
98978+
" enusc_dtypes = _set_data_types_not_mapped_var(enusc_notna)\n",
9897998979
" return enusc_dtypes"
9898098980
]
9898198981
},
@@ -98990,7 +98990,7 @@
9899098990
" enusc_filtered = enusc[relevant_var]\n",
9899198991
" return enusc_filtered\n",
9899298992
"\n",
98993-
"def _set_data_types(enusc_mapped):\n",
98993+
"def _set_data_types_not_mapped_var(enusc_mapped):\n",
9899498994
" \n",
9899598995
"\n",
9899698996
"def _rename_enusc(enusc_lower):\n",
@@ -99067,7 +99067,7 @@
9906799067
" return enusc_filled\n",
9906899068
"\n",
9906999069
"\n",
99070-
"def _set_data_types(enusc_filled):\n",
99070+
"def _set_data_types_not_mapped_var(enusc_filled):\n",
9907199071
" for value in floats: \n",
9907299072
" enusc_filled[value] = enusc_filled[value].astype(pd.Float64Dtype())\n",
9907399073
" for var in integers: \n",
@@ -99113,7 +99113,7 @@
9911399113
},
9911499114
{
9911599115
"cell_type": "code",
99116-
"execution_count": 7,
99116+
"execution_count": 12,
9911799117
"metadata": {},
9911899118
"outputs": [
9911999119
{
@@ -99258,7 +99258,7 @@
9925899258
" <td>NaN</td>\n",
9925999259
" <td>NaN</td>\n",
9926099260
" <td>NaN</td>\n",
99261-
" <td>NaN</td>\n",
99261+
" <td>&lt;NA&gt;</td>\n",
9926299262
" <td>2.0</td>\n",
9926399263
" <td>NaN</td>\n",
9926499264
" <td>Increased</td>\n",
@@ -99327,7 +99327,7 @@
9932799327
" <td>NaN</td>\n",
9932899328
" <td>NaN</td>\n",
9932999329
" <td>NaN</td>\n",
99330-
" <td>NaN</td>\n",
99330+
" <td>&lt;NA&gt;</td>\n",
9933199331
" <td>NaN</td>\n",
9933299332
" <td>NaN</td>\n",
9933399333
" <td>NaN</td>\n",
@@ -99396,7 +99396,7 @@
9939699396
" <td>NaN</td>\n",
9939799397
" <td>NaN</td>\n",
9939899398
" <td>NaN</td>\n",
99399-
" <td>NaN</td>\n",
99399+
" <td>&lt;NA&gt;</td>\n",
9940099400
" <td>NaN</td>\n",
9940199401
" <td>NaN</td>\n",
9940299402
" <td>NaN</td>\n",
@@ -99465,7 +99465,7 @@
9946599465
" <td>NaN</td>\n",
9946699466
" <td>NaN</td>\n",
9946799467
" <td>NaN</td>\n",
99468-
" <td>NaN</td>\n",
99468+
" <td>&lt;NA&gt;</td>\n",
9946999469
" <td>NaN</td>\n",
9947099470
" <td>NaN</td>\n",
9947199471
" <td>NaN</td>\n",
@@ -99534,7 +99534,7 @@
9953499534
" <td>NaN</td>\n",
9953599535
" <td>NaN</td>\n",
9953699536
" <td>NaN</td>\n",
99537-
" <td>NaN</td>\n",
99537+
" <td>&lt;NA&gt;</td>\n",
9953899538
" <td>NaN</td>\n",
9953999539
" <td>NaN</td>\n",
9954099540
" <td>NaN</td>\n",
@@ -99672,7 +99672,7 @@
9967299672
" <td>NaN</td>\n",
9967399673
" <td>NaN</td>\n",
9967499674
" <td>NaN</td>\n",
99675-
" <td>NaN</td>\n",
99675+
" <td>&lt;NA&gt;</td>\n",
9967699676
" <td>NaN</td>\n",
9967799677
" <td>NaN</td>\n",
9967899678
" <td>NaN</td>\n",
@@ -99741,7 +99741,7 @@
9974199741
" <td>NaN</td>\n",
9974299742
" <td>NaN</td>\n",
9974399743
" <td>NaN</td>\n",
99744-
" <td>NaN</td>\n",
99744+
" <td>&lt;NA&gt;</td>\n",
9974599745
" <td>2.0</td>\n",
9974699746
" <td>NaN</td>\n",
9974799747
" <td>Increased</td>\n",
@@ -99810,7 +99810,7 @@
9981099810
" <td>NaN</td>\n",
9981199811
" <td>NaN</td>\n",
9981299812
" <td>NaN</td>\n",
99813-
" <td>NaN</td>\n",
99813+
" <td>&lt;NA&gt;</td>\n",
9981499814
" <td>2.0</td>\n",
9981599815
" <td>NaN</td>\n",
9981699816
" <td>Increased</td>\n",
@@ -99879,7 +99879,7 @@
9987999879
" <td>NaN</td>\n",
9988099880
" <td>NaN</td>\n",
9988199881
" <td>NaN</td>\n",
99882-
" <td>NaN</td>\n",
99882+
" <td>&lt;NA&gt;</td>\n",
9988399883
" <td>NaN</td>\n",
9988499884
" <td>NaN</td>\n",
9988599885
" <td>NaN</td>\n",
@@ -99948,7 +99948,7 @@
9994899948
" <td>NaN</td>\n",
9994999949
" <td>NaN</td>\n",
9995099950
" <td>NaN</td>\n",
99951-
" <td>NaN</td>\n",
99951+
" <td>&lt;NA&gt;</td>\n",
9995299952
" <td>NaN</td>\n",
9995399953
" <td>NaN</td>\n",
9995499954
" <td>NaN</td>\n",
@@ -100219,17 +100219,17 @@
100219100219
"146293 NaN NaN \n",
100220100220
"\n",
100221100221
" reason_not_reporting_theft household_theft_victim theft_reported \\\n",
100222-
"0 NaN 2.0 NaN \n",
100223-
"1 NaN NaN NaN \n",
100224-
"2 NaN NaN NaN \n",
100225-
"3 NaN NaN NaN \n",
100226-
"4 NaN NaN NaN \n",
100222+
"0 <NA> 2.0 NaN \n",
100223+
"1 <NA> NaN NaN \n",
100224+
"2 <NA> NaN NaN \n",
100225+
"3 <NA> NaN NaN \n",
100226+
"4 <NA> NaN NaN \n",
100227100227
"... ... ... ... \n",
100228-
"146289 NaN NaN NaN \n",
100229-
"146290 NaN 2.0 NaN \n",
100230-
"146291 NaN 2.0 NaN \n",
100231-
"146292 NaN NaN NaN \n",
100232-
"146293 NaN NaN NaN \n",
100228+
"146289 <NA> NaN NaN \n",
100229+
"146290 <NA> 2.0 NaN \n",
100230+
"146291 <NA> 2.0 NaN \n",
100231+
"146292 <NA> NaN NaN \n",
100232+
"146293 <NA> NaN NaN \n",
100233100233
"\n",
100234100234
" crime_perception_national crime_perception_commune \\\n",
100235100235
"0 Increased Increased \n",
@@ -100325,7 +100325,7 @@
100325100325
"[146294 rows x 66 columns]"
100326100326
]
100327100327
},
100328-
"execution_count": 7,
100328+
"execution_count": 12,
100329100329
"metadata": {},
100330100330
"output_type": "execute_result"
100331100331
}
@@ -100337,7 +100337,7 @@
100337100337
},
100338100338
{
100339100339
"cell_type": "code",
100340-
"execution_count": 8,
100340+
"execution_count": 11,
100341100341
"metadata": {},
100342100342
"outputs": [
100343100343
{
@@ -100357,7 +100357,7 @@
100357100357
"Length: 66, dtype: object"
100358100358
]
100359100359
},
100360-
"execution_count": 8,
100360+
"execution_count": 11,
100361100361
"metadata": {},
100362100362
"output_type": "execute_result"
100363100363
}

0 commit comments

Comments
 (0)