-
Notifications
You must be signed in to change notification settings - Fork 0
/
rename_categories.py
157 lines (132 loc) · 5.38 KB
/
rename_categories.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import matplotlib.pyplot as plt
import matplotlib
import random
import seaborn as sns
import pandas as pd
import numpy as np
import gc
def rename_cat_type_suite(df_app, variable="NAME_TYPE_SUITE"):
cat = {"Unaccompanied": "Unaccompanied",
"Family": "Accompanied",
"Spouse, partner": "Accompanied",
"Children": "Accompanied",
"Other_B": "Accompanied",
"Other_A": "Accompanied",
"Group of people": "Accompanied"}
df_app = df_app.replace({variable: cat})
return (df_app)
def rename_cat_income_type(df_app, variable="NAME_INCOME_TYPE"):
cat = {"Working": "Working",
"State servant": "Working",
"Commercial associate": "Working",
"Pensioner": "Pensioner",
"Unemployed": "Unemployed",
"Student": "Unemployed",
"Businessman": "Working",
"Maternity leave": "Unemployed"}
df_app = df_app.replace({variable: cat})
return (df_app)
def rename_cat_education_type(df_app, variable="NAME_EDUCATION_TYPE"):
cat = {"Academic degree": "Higher_education",
"Higher education": "Higher_education",
"Secondary / secondary special": "Secondary_education",
"Incomplete higher": "Secondary_education",
"Lower secondary": "Lower_secondary",
"Secondary education":"Secondary_education"}
df_app = df_app.replace({variable: cat})
return (df_app)
def rename_cat_family_status(df_app, variable="NAME_FAMILY_STATUS"):
cat = {"Married": "Married",
"Civil marriage": "Married",
"Single / not married": "Single_and_related",
"Separated": "Single_and_related",
"Widow": "Single_and_related"}
df_app = df_app.replace({variable: cat})
return (df_app)
def rename_cat_housing_type(df_app, variable="NAME_HOUSING_TYPE"):
cat = {"With parents": "Social_or_equivalent_housing",
"Municipal apartment": "Social_or_equivalent_housing",
"Office apartment": "Social_or_equivalent_housing",
"Co-op apartment": "Social_or_equivalent_housing",
"Rented apartment": "House_or_apartment",
"House / apartment": "House_or_apartment"}
df_app = df_app.replace({variable: cat})
return (df_app)
def rename_organization_type(df_app, variable="ORGANIZATION_TYPE"):
cat = {'Business Entity Type 3': 'Business_Entity',
'School': 'School',
'Government': 'Government',
'Religion': 'Other',
'Other': 'Other',
'XNA': 'Other',
'Electricity': 'Construction',
'Medicine': 'Services',
'Business Entity Type 2': 'Business_Entity',
'Self-employed': 'Services',
'Transport: type 2': 'Transport',
'Construction': 'Construction',
'Housing': 'Construction',
'Kindergarten': 'School',
'Trade: type 7': 'Trade',
'Industry: type 11': 'Industry',
'Military': 'Government',
'Services': 'Services',
'Security Ministries': 'Government',
'Transport: type 4': 'Transport',
'Industry: type 1': 'Industry',
'Emergency': 'Government',
'Security': 'Government',
'Trade: type 2': 'Trade',
'University': 'School',
'Transport: type 3': 'Transport',
'Police': 'Government',
'Business Entity Type 1': 'Business_Entity',
'Postal': 'Government',
'Industry: type 4': 'Industry',
'Agriculture': 'Other',
'Restaurant': 'Services',
'Culture': 'Services',
'Hotel': 'Services',
'Industry: type 7': 'Industry',
'Trade: type 3': 'Trade',
'Industry: type 3': 'Industry',
'Bank': 'Services',
'Industry: type 9': 'Industry',
'Insurance': 'Services',
'Trade: type 6': 'Trade',
'Industry: type 2': 'Industry',
'Transport: type 1': 'Transport',
'Industry: type 12': 'Industry',
'Mobile': 'Services',
'Trade: type 1': 'Trade',
'Industry: type 5': 'Industry',
'Industry: type 10': 'Industry',
'Legal Services': 'Government',
'Advertising': 'Services',
'Trade: type 5': 'Trade',
'Cleaning': 'Services',
'Industry: type 13': 'Industry',
'Trade: type 4': 'Trade',
'Telecom': 'Construction',
'Industry: type 8': 'Industry',
'Realtor': 'Services',
'Industry: type 6': 'Industry'}
df_app = df_app.replace({variable: cat})
return (df_app)
def rename_cat_occupation_type(df_app, variable="OCCUPATION_TYPE"):
cat = {"Sales staff": "Sales_staff",
"Core staff": "Core_staff",
"High skill tech staff": "IT_staff",
"Medicine staff": "Medicine_staff",
"Security staff": "Security_staff",
"Cooking staff": "Restaurant_bar_staff",
"Cleaning staff": "Cleaning_staff",
"Private service staff": "Private_service_staff",
"Low-skill laborers": "Laborers",
"Waiters/barmen staff": "Restaurant_bar_staff",
"Realty agents": "Core_staff",
"HR staff": "Core_staff",
"IT staff": "IT_staff",
"Secretaries": "Core_staff"}
df_app = df_app.replace({variable: cat})
return (df_app)