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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import datetime
|
3 |
+
import requests
|
4 |
+
from offres_emploi import Api
|
5 |
+
from offres_emploi.utils import dt_to_str_iso
|
6 |
+
from dash import Dash, html, dcc, callback, Output, Input, dash_table, State, _dash_renderer
|
7 |
+
import plotly.express as px
|
8 |
+
import dash_mantine_components as dmc
|
9 |
+
from dash_iconify import DashIconify
|
10 |
+
import pandas as pd
|
11 |
+
from dotenv import load_dotenv
|
12 |
+
_dash_renderer._set_react_version("18.2.0")
|
13 |
+
import plotly.io as pio
|
14 |
+
|
15 |
+
# Create a customized version of the plotly_dark theme with a modified background color
|
16 |
+
custom_plotly_dark_theme = {
|
17 |
+
"layout": {
|
18 |
+
"paper_bgcolor": "#1E1E1E", # Update the paper background color
|
19 |
+
"plot_bgcolor": "#1E1E1E", # Update the plot background color
|
20 |
+
"font": {
|
21 |
+
"color": "#FFFFFF" # Update the font color
|
22 |
+
},
|
23 |
+
"xaxis": {
|
24 |
+
"gridcolor": "#333333", # Update the x-axis grid color
|
25 |
+
"zerolinecolor": "#666666" # Update the x-axis zero line color
|
26 |
+
},
|
27 |
+
"yaxis": {
|
28 |
+
"gridcolor": "#333333", # Update the y-axis grid color
|
29 |
+
"zerolinecolor": "#666666" # Update the y-axis zero line color
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
# Apply the customized theme to your Plotly figures
|
35 |
+
pio.templates["custom_plotly_dark"] = custom_plotly_dark_theme
|
36 |
+
pio.templates.default = "custom_plotly_dark"
|
37 |
+
|
38 |
+
load_dotenv()
|
39 |
+
|
40 |
+
def localisation():
|
41 |
+
ListCentroids = [
|
42 |
+
{ "ID": "01", "Longitude": 5.3245259, "Latitude":46.0666003 },
|
43 |
+
{ "ID": "02", "Longitude": 3.5960246, "Latitude": 49.5519632 },
|
44 |
+
{ "ID": "03", "Longitude": 3.065278, "Latitude": 46.4002783 },
|
45 |
+
{ "ID": "04", "Longitude": 6.2237688, "Latitude": 44.1105837 },
|
46 |
+
{ "ID": "05", "Longitude": 6.2018836, "Latitude": 44.6630487 },
|
47 |
+
{ "ID": "06", "Longitude": 7.0755745, "Latitude":43.9463082 },
|
48 |
+
{ "ID": "07", "Longitude": 4.3497308, "Latitude": 44.7626044 },
|
49 |
+
{ "ID": "08", "Longitude": 4.6234893, "Latitude": 49.6473884 },
|
50 |
+
{ "ID": "09", "Longitude": 1.6037147, "Latitude": 42.9696091 },
|
51 |
+
{ "ID": "10", "Longitude": 4.1394954, "Latitude": 48.2963286 },
|
52 |
+
{ "ID": "11", "Longitude": 2.3140163, "Latitude": 43.1111427 },
|
53 |
+
{ "ID": "12", "Longitude": 2.7365234, "Latitude": 44.2786323 },
|
54 |
+
{ "ID": "13", "Longitude": 5.0515492, "Latitude": 43.5539098 },
|
55 |
+
{ "ID": "14", "Longitude": -0.3930779, "Latitude": 49.1024215 },
|
56 |
+
{ "ID": "15", "Longitude": 2.6367657, "Latitude": 44.9643217 },
|
57 |
+
{ "ID": "16", "Longitude": 0.180475, "Latitude": 45.706264 },
|
58 |
+
{ "ID": "17", "Longitude": -0.7082589, "Latitude": 45.7629699 },
|
59 |
+
{ "ID": "18", "Longitude": 2.5292424, "Latitude": 47.0926687 },
|
60 |
+
{ "ID": "19", "Longitude": 1.8841811, "Latitude": 45.3622055 },
|
61 |
+
{ "ID": "2A", "Longitude": 8.9906834, "Latitude": 41.8619761 },
|
62 |
+
{ "ID": "2B", "Longitude": 9.275489, "Latitude": 42.372014 },
|
63 |
+
{ "ID": "21", "Longitude": 4.7870471, "Latitude": 47.4736746 },
|
64 |
+
{ "ID": "22", "Longitude": -2.9227591, "Latitude": 48.408402 },
|
65 |
+
{ "ID": "23", "Longitude": 2.0265508, "Latitude": 46.0837382 },
|
66 |
+
{ "ID": "24", "Longitude": 0.7140145, "Latitude": 45.1489678 },
|
67 |
+
{ "ID": "25", "Longitude": 6.3991355, "Latitude": 47.1879451 },
|
68 |
+
{ "ID": "26", "Longitude": 5.1717552, "Latitude": 44.8055408 },
|
69 |
+
{ "ID": "27", "Longitude": 0.9488116, "Latitude": 49.1460288 },
|
70 |
+
{ "ID": "28", "Longitude": 1.2793491, "Latitude": 48.3330017 },
|
71 |
+
{ "ID": "29", "Longitude": -4.1577074, "Latitude": 48.2869945 },
|
72 |
+
{ "ID": "30", "Longitude": 4.2650329, "Latitude": 43.9636468 },
|
73 |
+
{ "ID": "31", "Longitude": 1.2728958, "Latitude": 43.3671081 },
|
74 |
+
{ "ID": "32", "Longitude": 0.4220039, "Latitude": 43.657141 },
|
75 |
+
{ "ID": "33", "Longitude": -0.5760716, "Latitude": 44.8406068 },
|
76 |
+
{ "ID": "34", "Longitude": 3.4197556, "Latitude": 43.62585 },
|
77 |
+
{ "ID": "35", "Longitude": -1.6443812, "Latitude": 48.1801254 },
|
78 |
+
{ "ID": "36", "Longitude": 1.6509938, "Latitude": 46.7964222 },
|
79 |
+
{ "ID": "37", "Longitude": 0.7085619, "Latitude": 47.2802601 },
|
80 |
+
{ "ID": "38", "Longitude": 5.6230772, "Latitude": 45.259805 },
|
81 |
+
{ "ID": "39", "Longitude": 5.612871, "Latitude": 46.7398138 },
|
82 |
+
{ "ID": "40", "Longitude": -0.8771738, "Latitude": 44.0161251 },
|
83 |
+
{ "ID": "41", "Longitude": 1.3989178, "Latitude": 47.5866519 },
|
84 |
+
{ "ID": "42", "Longitude": 4.2262355, "Latitude": 45.7451186 },
|
85 |
+
{ "ID": "43", "Longitude": 3.8118151, "Latitude": 45.1473029 },
|
86 |
+
{ "ID": "44", "Longitude": -1.7642949, "Latitude": 47.4616509 },
|
87 |
+
{ "ID": "45", "Longitude": 2.2372695, "Latitude": 47.8631395 },
|
88 |
+
{ "ID": "46", "Longitude": 1.5732157, "Latitude": 44.6529284 },
|
89 |
+
{ "ID": "47", "Longitude": 0.4788052, "Latitude": 44.4027215 },
|
90 |
+
{ "ID": "48", "Longitude": 3.4991239, "Latitude": 44.5191573 },
|
91 |
+
{ "ID": "49", "Longitude": -0.5136056, "Latitude": 47.3945201 },
|
92 |
+
{ "ID": "50", "Longitude": -1.3203134, "Latitude": 49.0162072 },
|
93 |
+
{ "ID": "51", "Longitude": 4.2966555, "Latitude": 48.9479636 },
|
94 |
+
{ "ID": "52", "Longitude": 5.1325796, "Latitude": 48.1077196 },
|
95 |
+
{ "ID": "53", "Longitude": -0.7073921, "Latitude": 48.1225795 },
|
96 |
+
{ "ID": "54", "Longitude": 6.144792, "Latitude": 48.7995163 },
|
97 |
+
{ "ID": "55", "Longitude": 5.2888292, "Latitude": 49.0074545 },
|
98 |
+
{ "ID": "56", "Longitude": -2.8746938, "Latitude": 47.9239486 },
|
99 |
+
{ "ID": "57", "Longitude": 6.5610683, "Latitude": 49.0399233 },
|
100 |
+
{ "ID": "58", "Longitude": 3.5544332, "Latitude": 47.1122301 },
|
101 |
+
{ "ID": "59", "Longitude": 3.2466616, "Latitude": 50.4765414 },
|
102 |
+
{ "ID": "60", "Longitude": 2.4161734, "Latitude": 49.3852913 },
|
103 |
+
{ "ID": "61", "Longitude": 0.2248368, "Latitude": 48.5558919 },
|
104 |
+
{ "ID": "62", "Longitude": 2.2555152, "Latitude": 50.4646795 },
|
105 |
+
{ "ID": "63", "Longitude": 3.1322144, "Latitude": 45.7471805 },
|
106 |
+
{ "ID": "64", "Longitude": -0.793633, "Latitude": 43.3390984 },
|
107 |
+
{ "ID": "65", "Longitude": 0.1478724, "Latitude": 43.0526238 },
|
108 |
+
{ "ID": "66", "Longitude": 2.5239855, "Latitude": 42.5825094 },
|
109 |
+
{ "ID": "67", "Longitude": 7.5962225, "Latitude": 48.662515 },
|
110 |
+
{ "ID": "68", "Longitude": 7.2656284, "Latitude": 47.8586205 },
|
111 |
+
{ "ID": "69", "Longitude": 4.6859896, "Latitude": 45.8714754 },
|
112 |
+
{ "ID": "70", "Longitude": 6.1388571, "Latitude": 47.5904191 },
|
113 |
+
{ "ID": "71", "Longitude": 4.6394021, "Latitude": 46.5951234 },
|
114 |
+
{ "ID": "72", "Longitude": 0.1947322, "Latitude": 48.0041421 },
|
115 |
+
{ "ID": "73", "Longitude": 6.4662232, "Latitude": 45.4956055 },
|
116 |
+
{ "ID": "74", "Longitude": 6.3609606, "Latitude": 46.1045902 },
|
117 |
+
{ "ID": "75", "Longitude": 2.3416082, "Latitude": 48.8626759 },
|
118 |
+
{ "ID": "76", "Longitude": 1.025579, "Latitude": 49.6862911 },
|
119 |
+
{ "ID": "77", "Longitude": 2.8977309, "Latitude": 48.5957831 },
|
120 |
+
{ "ID": "78", "Longitude": 1.8080138, "Latitude": 48.7831982 },
|
121 |
+
{ "ID": "79", "Longitude": -0.3159014, "Latitude": 46.5490257 },
|
122 |
+
{ "ID": "80", "Longitude": 2.3380595, "Latitude": 49.9783317 },
|
123 |
+
{ "ID": "81", "Longitude": 2.2072751, "Latitude": 43.8524305 },
|
124 |
+
{ "ID": "82", "Longitude": 1.2649374, "Latitude": 44.1254902 },
|
125 |
+
{ "ID": "83", "Longitude": 6.1486127, "Latitude": 43.5007903 },
|
126 |
+
{ "ID": "84", "Longitude": 5.065418, "Latitude": 44.0001599 },
|
127 |
+
{ "ID": "85", "Longitude": -1.3956692, "Latitude": 46.5929102 },
|
128 |
+
{ "ID": "86", "Longitude": 0.4953679, "Latitude": 46.5719095 },
|
129 |
+
{ "ID": "87", "Longitude": 1.2500647, "Latitude": 45.9018644 },
|
130 |
+
{ "ID": "88", "Longitude": 6.349702, "Latitude": 48.1770451 },
|
131 |
+
{ "ID": "89", "Longitude": 3.5634078, "Latitude": 47.8474664 },
|
132 |
+
{ "ID": "90", "Longitude": 6.9498114, "Latitude": 47.6184394 },
|
133 |
+
{ "ID": "91", "Longitude": 2.2714555, "Latitude": 48.5203114 },
|
134 |
+
{ "ID": "92", "Longitude": 2.2407148, "Latitude": 48.835321 },
|
135 |
+
{ "ID": "93", "Longitude": 2.4811577, "Latitude": 48.9008719 },
|
136 |
+
{ "ID": "94", "Longitude": 2.4549766, "Latitude": 48.7832368 },
|
137 |
+
{ "ID": "95", "Longitude": 2.1802056, "Latitude": 49.076488 },
|
138 |
+
{ "ID": "974", "Longitude": 55.536384, "Latitude": -21.115141 },
|
139 |
+
{ "ID": "973", "Longitude": -53.125782, "Latitude": 3.933889 },
|
140 |
+
{ "ID": "972", "Longitude": -61.024174, "Latitude": 14.641528 },
|
141 |
+
{ "ID": "971", "Longitude": -61.551, "Latitude": 16.265 }
|
142 |
+
]
|
143 |
+
|
144 |
+
return ListCentroids
|
145 |
+
|
146 |
+
def connexion_France_Travail():
|
147 |
+
client = Api(client_id=os.getenv('POLE_EMPLOI_CLIENT_ID'),
|
148 |
+
client_secret=os.getenv('POLE_EMPLOI_CLIENT_SECRET'))
|
149 |
+
return client
|
150 |
+
|
151 |
+
def API_France_Travail(romeListArray):
|
152 |
+
client = connexion_France_Travail()
|
153 |
+
todayDate = datetime.datetime.today()
|
154 |
+
month, year = (todayDate.month-1, todayDate.year) if todayDate.month != 1 else (12, todayDate.year-1)
|
155 |
+
start_dt = todayDate.replace(day=1, month=month, year=year)
|
156 |
+
end_dt = datetime.datetime.today()
|
157 |
+
results = []
|
158 |
+
for k in romeListArray:
|
159 |
+
if k[0:1] == ' ':
|
160 |
+
k = k[1:]
|
161 |
+
params = {"motsCles": k.replace('/', '').replace('-', '').replace(',', '').replace(' ', ','),'minCreationDate': dt_to_str_iso(start_dt),'maxCreationDate': dt_to_str_iso(end_dt),'range':'0-149'}
|
162 |
+
try:
|
163 |
+
search_on_big_data = client.search(params=params)
|
164 |
+
results += search_on_big_data["resultats"]
|
165 |
+
except:
|
166 |
+
print("Il n'y a pas d'offres d'emploi.")
|
167 |
+
|
168 |
+
results_df = pd.DataFrame(results)
|
169 |
+
return results_df
|
170 |
+
|
171 |
+
theme_toggle = dmc.Tooltip(
|
172 |
+
dmc.ActionIcon(
|
173 |
+
[
|
174 |
+
dmc.Paper(DashIconify(icon="radix-icons:sun", width=25), darkHidden=True),
|
175 |
+
dmc.Paper(DashIconify(icon="radix-icons:moon", width=25), lightHidden=True),
|
176 |
+
],
|
177 |
+
variant="transparent",
|
178 |
+
color="yellow",
|
179 |
+
id="color-scheme-toggle",
|
180 |
+
size="lg",
|
181 |
+
ms="auto",
|
182 |
+
),
|
183 |
+
label="Changez de thème",
|
184 |
+
position="left",
|
185 |
+
withArrow=True,
|
186 |
+
arrowSize=6,
|
187 |
+
)
|
188 |
+
|
189 |
+
styleTitle = {
|
190 |
+
"textAlign": "center",
|
191 |
+
"color": dmc.DEFAULT_THEME["colors"]["orange"][4]
|
192 |
+
}
|
193 |
+
|
194 |
+
styleToggle = {
|
195 |
+
"marginTop":"25px",
|
196 |
+
"textAlign": "right",
|
197 |
+
}
|
198 |
+
app = Dash(external_stylesheets=dmc.styles.ALL)
|
199 |
+
|
200 |
+
app.layout = dmc.MantineProvider(
|
201 |
+
[
|
202 |
+
html.Div(
|
203 |
+
children=[
|
204 |
+
dmc.Container(
|
205 |
+
children=[
|
206 |
+
dmc.Grid(
|
207 |
+
children=[
|
208 |
+
dmc.GridCol(html.Div(
|
209 |
+
dmc.MultiSelect(
|
210 |
+
label="Selectionnez vos Codes ROME",
|
211 |
+
placeholder="Select vos Codes ROME parmi la liste",
|
212 |
+
id="framework-multi-select",
|
213 |
+
value=['K2105', 'L1101', 'L1202', 'L1507', 'L1508', 'L1509'],
|
214 |
+
data=[
|
215 |
+
{"value": "K2105", "label": "K2105"},
|
216 |
+
{"value": "L1101", "label": "L1101"},
|
217 |
+
{"value": "L1202", "label": "L1202"},
|
218 |
+
{"value": "L1507", "label": "L1507"},
|
219 |
+
{"value": "L1508", "label": "L1508"},
|
220 |
+
{"value": "L1509", "label": "L1509"},
|
221 |
+
],
|
222 |
+
w=600,
|
223 |
+
mb=10,
|
224 |
+
styles={
|
225 |
+
"input": {"borderColor": dmc.DEFAULT_THEME["colors"]["orange"][2]},
|
226 |
+
"label": {"color": dmc.DEFAULT_THEME["colors"]["orange"][4]},
|
227 |
+
},
|
228 |
+
)
|
229 |
+
), span=6),
|
230 |
+
dmc.GridCol(html.Div(dmc.Title(f"Le marché et les statistiques de l'emploi", order=1, size="30", my="20", style=styleTitle)), span=5),
|
231 |
+
dmc.GridCol(html.Div(theme_toggle, style=styleToggle), span=1),
|
232 |
+
dmc.GridCol(html.Div(
|
233 |
+
dcc.Graph(id="figRepartition",selectedData={'points': [{'hovertext': ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','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','971','972','973','974']}]}),
|
234 |
+
), span=6),
|
235 |
+
dmc.GridCol(html.Div(
|
236 |
+
dcc.Graph(id="figEmplois"),
|
237 |
+
), span=6),
|
238 |
+
dmc.GridCol(html.Div(
|
239 |
+
dcc.Graph(id="figContrats"),
|
240 |
+
), span=6),
|
241 |
+
dmc.GridCol(html.Div(
|
242 |
+
dcc.Graph(id="figExperiences"),
|
243 |
+
), span=6),
|
244 |
+
dmc.GridCol(html.Div(
|
245 |
+
dcc.Graph(id="figCompetences"),
|
246 |
+
), span=6),
|
247 |
+
dmc.GridCol(html.Div(
|
248 |
+
dcc.Graph(id="figTransversales"),
|
249 |
+
), span=6),
|
250 |
+
],
|
251 |
+
gutter="xs",
|
252 |
+
)
|
253 |
+
],size="xxl",fluid=True
|
254 |
+
),
|
255 |
+
]
|
256 |
+
)
|
257 |
+
],
|
258 |
+
id="mantine-provider",
|
259 |
+
forceColorScheme="dark",
|
260 |
+
theme={
|
261 |
+
"primaryColor": "indigo",
|
262 |
+
"fontFamily": "'Inter', sans-serif",
|
263 |
+
"components": {
|
264 |
+
"Button": {"defaultProps": {"fw": 400}},
|
265 |
+
"Alert": {"styles": {"title": {"fontWeight": 500}}},
|
266 |
+
"AvatarGroup": {"styles": {"truncated": {"fontWeight": 500}}},
|
267 |
+
"Badge": {"styles": {"root": {"fontWeight": 500}}},
|
268 |
+
"Progress": {"styles": {"label": {"fontWeight": 500}}},
|
269 |
+
"RingProgress": {"styles": {"label": {"fontWeight": 500}}},
|
270 |
+
"CodeHighlightTabs": {"styles": {"file": {"padding": 12}}},
|
271 |
+
"Table": {
|
272 |
+
"defaultProps": {
|
273 |
+
"highlightOnHover": True,
|
274 |
+
"withTableBorder": True,
|
275 |
+
"verticalSpacing": "sm",
|
276 |
+
"horizontalSpacing": "md",
|
277 |
+
}
|
278 |
+
},
|
279 |
+
},
|
280 |
+
# add your colors
|
281 |
+
"colors": {
|
282 |
+
"deepBlue": ["#E9EDFC", "#C1CCF6", "#99ABF0"], # 10 color elements
|
283 |
+
},
|
284 |
+
"shadows": {
|
285 |
+
# other shadows (xs, sm, lg) will be merged from default theme
|
286 |
+
"md": "1px 1px 3px rgba(0,0,0,.25)",
|
287 |
+
"xl": "5px 5px 3px rgba(0,0,0,.25)",
|
288 |
+
},
|
289 |
+
"headings": {
|
290 |
+
"fontFamily": "Roboto, sans-serif",
|
291 |
+
"sizes": {
|
292 |
+
"h1": {"fontSize": 30},
|
293 |
+
},
|
294 |
+
},
|
295 |
+
},
|
296 |
+
)
|
297 |
+
@callback(
|
298 |
+
Output("mantine-provider", "forceColorScheme"),
|
299 |
+
Input("color-scheme-toggle", "n_clicks"),
|
300 |
+
State("mantine-provider", "forceColorScheme"),
|
301 |
+
prevent_initial_call=True,
|
302 |
+
)
|
303 |
+
def switch_theme(_, theme):
|
304 |
+
return "dark" if theme == "light" else "light"
|
305 |
+
|
306 |
+
@callback(
|
307 |
+
Output(component_id='figRepartition', component_property='figure'),
|
308 |
+
Output(component_id='figCompetences', component_property='figure'),
|
309 |
+
Output(component_id='figTransversales', component_property='figure'),
|
310 |
+
Input(component_id='framework-multi-select', component_property='value'),
|
311 |
+
Input("mantine-provider", "forceColorScheme"),
|
312 |
+
)
|
313 |
+
def create_repartition(array_value, theme):
|
314 |
+
if theme == "dark":
|
315 |
+
template = "plotly_dark"
|
316 |
+
paper_bgcolor = 'rgba(36, 36, 36, 1)'
|
317 |
+
plot_bgcolor = 'rgba(36, 36, 36, 1)'
|
318 |
+
else:
|
319 |
+
template = "ggplot2"
|
320 |
+
paper_bgcolor = 'rgba(255, 255, 255, 1)'
|
321 |
+
plot_bgcolor = 'rgba(255, 255, 255, 1)'
|
322 |
+
|
323 |
+
df_FT = API_France_Travail(array_value)
|
324 |
+
df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail']].copy()
|
325 |
+
df["lieuTravail"] = df["lieuTravail"].apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
|
326 |
+
df.drop(df[df['lieuTravail'] == 'Fra'].index, inplace = True)
|
327 |
+
df.drop(df[df['lieuTravail'] == 'FRA'].index, inplace = True)
|
328 |
+
df.drop(df[df['lieuTravail'] == 'Ile'].index, inplace = True)
|
329 |
+
df.drop(df[df['lieuTravail'] == 'Mar'].index, inplace = True)
|
330 |
+
df.drop(df[df['lieuTravail'] == 'Bou'].index, inplace = True)
|
331 |
+
df.drop(df[df['lieuTravail'] == '976'].index, inplace = True)
|
332 |
+
|
333 |
+
######## localisation ########
|
334 |
+
ListCentroids = localisation()
|
335 |
+
df_localisation = df.groupby('lieuTravail').size().reset_index(name='obs')
|
336 |
+
df_localisation = df_localisation.sort_values(by=['lieuTravail'])
|
337 |
+
df_localisation['longitude'] = df_localisation['lieuTravail']
|
338 |
+
df_localisation['latitude'] = df_localisation['lieuTravail']
|
339 |
+
df_localisation["longitude"] = df_localisation['longitude'].apply(lambda x:[loc['Longitude'] for loc in ListCentroids if loc['ID'] == x]).apply(lambda x:''.join(map(str, x)))
|
340 |
+
df_localisation["longitude"] = pd.to_numeric(df_localisation["longitude"], downcast="float")
|
341 |
+
df_localisation["latitude"] = df_localisation['latitude'].apply(lambda x:[loc['Latitude'] for loc in ListCentroids if loc['ID'] == x]).apply(lambda x:''.join(map(str, x)))
|
342 |
+
df_localisation["latitude"] = pd.to_numeric(df_localisation["latitude"], downcast="float")
|
343 |
+
res = requests.get(
|
344 |
+
"https://raw.githubusercontent.com/codeforgermany/click_that_hood/main/public/data/france-regions.geojson"
|
345 |
+
)
|
346 |
+
fig_localisation = px.scatter_mapbox(df_localisation, lat="latitude", lon="longitude", height=600, template=template, title="La répartition géographique des emplois", hover_name="lieuTravail", size="obs").update_layout(
|
347 |
+
mapbox={
|
348 |
+
"style": "carto-positron",
|
349 |
+
"center": {"lon": 2, "lat" : 47},
|
350 |
+
"zoom": 4.5,
|
351 |
+
"layers": [
|
352 |
+
{
|
353 |
+
"source": res.json(),
|
354 |
+
"type": "line",
|
355 |
+
"color": "green",
|
356 |
+
"line": {"width": 0},
|
357 |
+
}
|
358 |
+
],
|
359 |
+
},font=dict(size=10),paper_bgcolor=paper_bgcolor,autosize=True,clickmode='event+select'
|
360 |
+
)
|
361 |
+
|
362 |
+
df_FT.dropna(subset=['qualitesProfessionnelles','formations','competences'], inplace=True)
|
363 |
+
df_FT["competences"] = df_FT["competences"].apply(lambda x:[str(e['libelle']) for e in x]).apply(lambda x:'; '.join(map(str, x)))
|
364 |
+
df_FT["qualitesProfessionnelles"] = df_FT["qualitesProfessionnelles"].apply(lambda x:[str(e['libelle']) + ": " + str(e['description']) for e in x]).apply(lambda x:'; '.join(map(str, x)))
|
365 |
+
|
366 |
+
######## Compétences professionnelles ########
|
367 |
+
df_comp = df_FT
|
368 |
+
df_comp['competences'] = df_FT['competences'].str.split(';')
|
369 |
+
df_comp = df_comp.explode('competences')
|
370 |
+
df_comp = df_comp.groupby('competences').size().reset_index(name='obs')
|
371 |
+
df_comp = df_comp.sort_values(by=['obs'])
|
372 |
+
df_comp = df_comp.iloc[-20:]
|
373 |
+
fig_competences = px.bar(df_comp, x='obs', y='competences', orientation='h', color='obs', height=600, template=template, title="Les principales compétences professionnelles", labels={'obs':'nombre'}, color_continuous_scale="Teal", text_auto=True).update_layout(font=dict(size=10),paper_bgcolor=paper_bgcolor,plot_bgcolor=plot_bgcolor,autosize=True).update_traces(hovertemplate=df_comp["competences"] + ' <br>Nombre : %{x}', y=[y[:100] + "..." for y in df_comp['competences']], showlegend=False)
|
374 |
+
|
375 |
+
######## Compétences transversales ########
|
376 |
+
df_transversales = df_FT
|
377 |
+
df_transversales['qualitesProfessionnelles'] = df_FT['qualitesProfessionnelles'].str.split(';')
|
378 |
+
df_comptransversales = df_transversales.explode('qualitesProfessionnelles')
|
379 |
+
df_comptransversales = df_comptransversales.groupby('qualitesProfessionnelles').size().reset_index(name='obs')
|
380 |
+
df_comptransversales = df_comptransversales.sort_values(by=['obs'])
|
381 |
+
df_comptransversales = df_comptransversales.iloc[-20:]
|
382 |
+
fig_transversales = px.bar(df_comptransversales, x='obs', y='qualitesProfessionnelles', orientation='h', color='obs', height=600, template=template, title="Les principales compétences transversales", labels={'obs':'nombre'}, color_continuous_scale="Teal", text_auto=True).update_layout(font=dict(size=10),paper_bgcolor=paper_bgcolor,plot_bgcolor=plot_bgcolor,autosize=True).update_traces(hovertemplate=df_comptransversales["qualitesProfessionnelles"] + ' <br>Nombre : %{x}', y=[y[:80] + "..." for y in df_comptransversales["qualitesProfessionnelles"]], showlegend=False)
|
383 |
+
|
384 |
+
return fig_localisation, fig_competences, fig_transversales
|
385 |
+
|
386 |
+
def create_emploi(df, theme):
|
387 |
+
if theme == "dark":
|
388 |
+
template = "plotly_dark"
|
389 |
+
paper_bgcolor = 'rgba(36, 36, 36, 1)'
|
390 |
+
plot_bgcolor = 'rgba(36, 36, 36, 1)'
|
391 |
+
else:
|
392 |
+
template = "ggplot2"
|
393 |
+
paper_bgcolor = 'rgba(255, 255, 255, 1)'
|
394 |
+
plot_bgcolor = 'rgba(255, 255, 255, 1)'
|
395 |
+
######## Emplois ########
|
396 |
+
df_intitule = df.groupby('intitule').size().reset_index(name='obs')
|
397 |
+
df_intitule = df_intitule.sort_values(by=['obs'])
|
398 |
+
df_intitule = df_intitule.iloc[-25:]
|
399 |
+
fig_intitule = px.bar(df_intitule, x='obs', y='intitule', height=600, orientation='h', color='obs', template=template, title="Les principaux emplois", labels={'obs':'nombre'}, color_continuous_scale="Teal", text_auto=True).update_layout(font=dict(size=10),paper_bgcolor=paper_bgcolor,plot_bgcolor=plot_bgcolor, autosize=True).update_traces(hovertemplate=df_intitule["intitule"] + ' <br>Nombre : %{x}', y=[y[:100] + "..." for y in df_intitule["intitule"]], showlegend=False)
|
400 |
+
|
401 |
+
return fig_intitule
|
402 |
+
|
403 |
+
def create_contrat(df, theme):
|
404 |
+
if theme == "dark":
|
405 |
+
template = "plotly_dark"
|
406 |
+
paper_bgcolor = 'rgba(36, 36, 36, 1)'
|
407 |
+
else:
|
408 |
+
template = "ggplot2"
|
409 |
+
paper_bgcolor = 'rgba(255, 255, 255, 1)'
|
410 |
+
|
411 |
+
######## Types de contrat ########
|
412 |
+
df_contrat = df.groupby('typeContratLibelle').size().reset_index(name='obs')
|
413 |
+
fig_contrat = px.pie(df_contrat, names='typeContratLibelle', values='obs', color='obs', height=600, template=template, title="Les types de contrat", labels={'obs':'nombre'}, color_discrete_sequence=px.colors.qualitative.Safe).update_traces(textposition='inside', textinfo='percent+label').update_layout(font=dict(size=10),paper_bgcolor=paper_bgcolor)
|
414 |
+
|
415 |
+
return fig_contrat
|
416 |
+
|
417 |
+
def create_experience(df, theme):
|
418 |
+
if theme == "dark":
|
419 |
+
template = "plotly_dark"
|
420 |
+
paper_bgcolor = 'rgba(36, 36, 36, 1)'
|
421 |
+
else:
|
422 |
+
template = "ggplot2"
|
423 |
+
paper_bgcolor = 'rgba(255, 255, 255, 1)'
|
424 |
+
######## Expériences professionnelles ########
|
425 |
+
df_experience = df.groupby('experienceLibelle').size().reset_index(name='obs')
|
426 |
+
fig_experience = px.pie(df_experience, names='experienceLibelle', values='obs', color='obs', height=600, template=template, title="Les expériences professionnelles", labels={'obs':'nombre'}, color_discrete_sequence=px.colors.qualitative.Safe).update_traces(textposition='inside', textinfo='percent+label').update_layout(font=dict(size=10),paper_bgcolor=paper_bgcolor)
|
427 |
+
|
428 |
+
return fig_experience
|
429 |
+
|
430 |
+
@callback(
|
431 |
+
Output(component_id='figEmplois', component_property='figure'),
|
432 |
+
Input('figRepartition', 'selectedData'),
|
433 |
+
Input(component_id='framework-multi-select', component_property='value'),
|
434 |
+
Input("mantine-provider", "forceColorScheme"),
|
435 |
+
)
|
436 |
+
|
437 |
+
def update_emploi(selectedData, array_value, theme):
|
438 |
+
options = []
|
439 |
+
if selectedData != None:
|
440 |
+
if type(selectedData['points'][0]['hovertext']) == str:
|
441 |
+
options.append(selectedData['points'][0]['hovertext'])
|
442 |
+
else:
|
443 |
+
options = selectedData['points'][0]['hovertext']
|
444 |
+
else:
|
445 |
+
options = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','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','971','972','973','974']
|
446 |
+
|
447 |
+
df_FT = API_France_Travail(array_value)
|
448 |
+
df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail']].copy()
|
449 |
+
df["lieuTravail"] = df["lieuTravail"].apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
|
450 |
+
df.drop(df[df['lieuTravail'] == 'Fra'].index, inplace = True)
|
451 |
+
df.drop(df[df['lieuTravail'] == 'FRA'].index, inplace = True)
|
452 |
+
df.drop(df[df['lieuTravail'] == 'Ile'].index, inplace = True)
|
453 |
+
df.drop(df[df['lieuTravail'] == 'Mar'].index, inplace = True)
|
454 |
+
df.drop(df[df['lieuTravail'] == 'Bou'].index, inplace = True)
|
455 |
+
df.drop(df[df['lieuTravail'] == '976'].index, inplace = True)
|
456 |
+
df = df[df['lieuTravail'].isin(options)]
|
457 |
+
return create_emploi(df, theme)
|
458 |
+
|
459 |
+
@callback(
|
460 |
+
Output(component_id='figContrats', component_property='figure'),
|
461 |
+
Input('figRepartition', 'selectedData'),
|
462 |
+
Input(component_id='framework-multi-select', component_property='value'),
|
463 |
+
Input("mantine-provider", "forceColorScheme"),
|
464 |
+
)
|
465 |
+
|
466 |
+
def update_contrat(selectedData, array_value, theme):
|
467 |
+
options = []
|
468 |
+
if selectedData != None:
|
469 |
+
if type(selectedData['points'][0]['hovertext']) == str:
|
470 |
+
options.append(selectedData['points'][0]['hovertext'])
|
471 |
+
else:
|
472 |
+
options = selectedData['points'][0]['hovertext']
|
473 |
+
else:
|
474 |
+
options = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','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','971','972','973','974']
|
475 |
+
|
476 |
+
df_FT = API_France_Travail(array_value)
|
477 |
+
df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail']].copy()
|
478 |
+
df["lieuTravail"] = df["lieuTravail"].apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
|
479 |
+
df.drop(df[df['lieuTravail'] == 'Fra'].index, inplace = True)
|
480 |
+
df.drop(df[df['lieuTravail'] == 'FRA'].index, inplace = True)
|
481 |
+
df.drop(df[df['lieuTravail'] == 'Ile'].index, inplace = True)
|
482 |
+
df.drop(df[df['lieuTravail'] == 'Mar'].index, inplace = True)
|
483 |
+
df.drop(df[df['lieuTravail'] == 'Bou'].index, inplace = True)
|
484 |
+
df.drop(df[df['lieuTravail'] == '976'].index, inplace = True)
|
485 |
+
df = df[df['lieuTravail'].isin(options)]
|
486 |
+
|
487 |
+
return create_contrat(df, theme)
|
488 |
+
|
489 |
+
@callback(
|
490 |
+
Output(component_id='figExperiences', component_property='figure'),
|
491 |
+
Input('figRepartition', 'selectedData'),
|
492 |
+
Input(component_id='framework-multi-select', component_property='value'),
|
493 |
+
Input("mantine-provider", "forceColorScheme"),
|
494 |
+
)
|
495 |
+
|
496 |
+
def update_experience(selectedData, array_value, theme):
|
497 |
+
options = []
|
498 |
+
if selectedData != None:
|
499 |
+
if type(selectedData['points'][0]['hovertext']) == str:
|
500 |
+
options.append(selectedData['points'][0]['hovertext'])
|
501 |
+
else:
|
502 |
+
options = selectedData['points'][0]['hovertext']
|
503 |
+
else:
|
504 |
+
options = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','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','971','972','973','974']
|
505 |
+
|
506 |
+
df_FT = API_France_Travail(array_value)
|
507 |
+
df = df_FT[['intitule','typeContratLibelle','experienceLibelle','lieuTravail']].copy()
|
508 |
+
df["lieuTravail"] = df["lieuTravail"].apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
|
509 |
+
df.drop(df[df['lieuTravail'] == 'Fra'].index, inplace = True)
|
510 |
+
df.drop(df[df['lieuTravail'] == 'FRA'].index, inplace = True)
|
511 |
+
df.drop(df[df['lieuTravail'] == 'Ile'].index, inplace = True)
|
512 |
+
df.drop(df[df['lieuTravail'] == 'Mar'].index, inplace = True)
|
513 |
+
df.drop(df[df['lieuTravail'] == 'Bou'].index, inplace = True)
|
514 |
+
df.drop(df[df['lieuTravail'] == '976'].index, inplace = True)
|
515 |
+
df = df[df['lieuTravail'].isin(options)]
|
516 |
+
|
517 |
+
return create_experience(df, theme)
|
518 |
+
|
519 |
+
if __name__ == '__main__':
|
520 |
+
app.run(debug=True)
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dash
|
2 |
+
dash-mantine-components==0.14.6
|
3 |
+
dash-iconify
|
4 |
+
pandas
|
5 |
+
api-offres-emploi==0.0.2
|
6 |
+
plotly
|
7 |
+
python-dotenv
|