datacipen commited on
Commit
f712374
1 Parent(s): d23c725

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +144 -0
main.py CHANGED
@@ -74,6 +74,112 @@ def removeTags(all):
74
  data.decompose()
75
  return ' '.join(all.stripped_strings)
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  def modele(document):
78
  match document:
79
  case "Note de composante sectorielle":
@@ -269,6 +375,44 @@ async def on_action(action):
269
  df_experience = finals_df.groupby('experienceLibelle').size().reset_index(name='obs')
270
  fig_experience = px.pie(df_experience, names='experienceLibelle', width=800, height=800, values='obs', color='obs', 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,color="RebeccaPurple"))
271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  await action.remove()
273
 
274
  @cl.action_callback("saveMemory")
 
74
  data.decompose()
75
  return ' '.join(all.stripped_strings)
76
 
77
+ def localisation():
78
+ ListCentroids = [
79
+ { "ID": "01", "Longitude": 5.3245259, "Latitude":46.0666003 },
80
+ { "ID": "02", "Longitude": 3.5960246, "Latitude": 49.5519632 },
81
+ { "ID": "03", "Longitude": 3.065278, "Latitude": 46.4002783 },
82
+ { "ID": "04", "Longitude": 6.2237688, "Latitude": 44.1105837 },
83
+ { "ID": "05", "Longitude": 6.2018836, "Latitude": 44.6630487 },
84
+ { "ID": "06", "Longitude": 7.0755745, "Latitude":43.9463082 },
85
+ { "ID": "07", "Longitude": 4.3497308, "Latitude": 44.7626044 },
86
+ { "ID": "08", "Longitude": 4.6234893, "Latitude": 49.6473884 },
87
+ { "ID": "09", "Longitude": 1.6037147, "Latitude": 42.9696091 },
88
+ { "ID": "10", "Longitude": 4.1394954, "Latitude": 48.2963286 },
89
+ { "ID": "11", "Longitude": 2.3140163, "Latitude": 43.1111427 },
90
+ { "ID": "12", "Longitude": 2.7365234, "Latitude": 44.2786323 },
91
+ { "ID": "13", "Longitude": 5.0515492, "Latitude": 43.5539098 },
92
+ { "ID": "14", "Longitude": -0.3930779, "Latitude": 49.1024215 },
93
+ { "ID": "15", "Longitude": 2.6367657, "Latitude": 44.9643217 },
94
+ { "ID": "16", "Longitude": 0.180475, "Latitude": 45.706264 },
95
+ { "ID": "17", "Longitude": -0.7082589, "Latitude": 45.7629699 },
96
+ { "ID": "18", "Longitude": 2.5292424, "Latitude": 47.0926687 },
97
+ { "ID": "19", "Longitude": 1.8841811, "Latitude": 45.3622055 },
98
+ { "ID": "2A", "Longitude": 8.9906834, "Latitude": 41.8619761 },
99
+ { "ID": "2B", "Longitude": 9.275489, "Latitude": 42.372014 },
100
+ { "ID": "21", "Longitude": 4.7870471, "Latitude": 47.4736746 },
101
+ { "ID": "22", "Longitude": -2.9227591, "Latitude": 48.408402 },
102
+ { "ID": "23", "Longitude": 2.0265508, "Latitude": 46.0837382 },
103
+ { "ID": "24", "Longitude": 0.7140145, "Latitude": 45.1489678 },
104
+ { "ID": "25", "Longitude": 6.3991355, "Latitude": 47.1879451 },
105
+ { "ID": "26", "Longitude": 5.1717552, "Latitude": 44.8055408 },
106
+ { "ID": "27", "Longitude": 0.9488116, "Latitude": 49.1460288 },
107
+ { "ID": "28", "Longitude": 1.2793491, "Latitude": 48.3330017 },
108
+ { "ID": "29", "Longitude": -4.1577074, "Latitude": 48.2869945 },
109
+ { "ID": "30", "Longitude": 4.2650329, "Latitude": 43.9636468 },
110
+ { "ID": "31", "Longitude": 1.2728958, "Latitude": 43.3671081 },
111
+ { "ID": "32", "Longitude": 0.4220039, "Latitude": 43.657141 },
112
+ { "ID": "33", "Longitude": -0.5760716, "Latitude": 44.8406068 },
113
+ { "ID": "34", "Longitude": 3.4197556, "Latitude": 43.62585 },
114
+ { "ID": "35", "Longitude": -1.6443812, "Latitude": 48.1801254 },
115
+ { "ID": "36", "Longitude": 1.6509938, "Latitude": 46.7964222 },
116
+ { "ID": "37", "Longitude": 0.7085619, "Latitude": 47.2802601 },
117
+ { "ID": "38", "Longitude": 5.6230772, "Latitude": 45.259805 },
118
+ { "ID": "39", "Longitude": 5.612871, "Latitude": 46.7398138 },
119
+ { "ID": "40", "Longitude": -0.8771738, "Latitude": 44.0161251 },
120
+ { "ID": "41", "Longitude": 1.3989178, "Latitude": 47.5866519 },
121
+ { "ID": "42", "Longitude": 4.2262355, "Latitude": 45.7451186 },
122
+ { "ID": "43", "Longitude": 3.8118151, "Latitude": 45.1473029 },
123
+ { "ID": "44", "Longitude": -1.7642949, "Latitude": 47.4616509 },
124
+ { "ID": "45", "Longitude": 2.2372695, "Latitude": 47.8631395 },
125
+ { "ID": "46", "Longitude": 1.5732157, "Latitude": 44.6529284 },
126
+ { "ID": "47", "Longitude": 0.4788052, "Latitude": 44.4027215 },
127
+ { "ID": "48", "Longitude": 3.4991239, "Latitude": 44.5191573 },
128
+ { "ID": "49", "Longitude": -0.5136056, "Latitude": 47.3945201 },
129
+ { "ID": "50", "Longitude": -1.3203134, "Latitude": 49.0162072 },
130
+ { "ID": "51", "Longitude": 4.2966555, "Latitude": 48.9479636 },
131
+ { "ID": "52", "Longitude": 5.1325796, "Latitude": 48.1077196 },
132
+ { "ID": "53", "Longitude": -0.7073921, "Latitude": 48.1225795 },
133
+ { "ID": "54", "Longitude": 6.144792, "Latitude": 48.7995163 },
134
+ { "ID": "55", "Longitude": 5.2888292, "Latitude": 49.0074545 },
135
+ { "ID": "56", "Longitude": -2.8746938, "Latitude": 47.9239486 },
136
+ { "ID": "57", "Longitude": 6.5610683, "Latitude": 49.0399233 },
137
+ { "ID": "58", "Longitude": 3.5544332, "Latitude": 47.1122301 },
138
+ { "ID": "59", "Longitude": 3.2466616, "Latitude": 50.4765414 },
139
+ { "ID": "60", "Longitude": 2.4161734, "Latitude": 49.3852913 },
140
+ { "ID": "61", "Longitude": 0.2248368, "Latitude": 48.5558919 },
141
+ { "ID": "62", "Longitude": 2.2555152, "Latitude": 50.4646795 },
142
+ { "ID": "63", "Longitude": 3.1322144, "Latitude": 45.7471805 },
143
+ { "ID": "64", "Longitude": -0.793633, "Latitude": 43.3390984 },
144
+ { "ID": "65", "Longitude": 0.1478724, "Latitude": 43.0526238 },
145
+ { "ID": "66", "Longitude": 2.5239855, "Latitude": 42.5825094 },
146
+ { "ID": "67", "Longitude": 7.5962225, "Latitude": 48.662515 },
147
+ { "ID": "68", "Longitude": 7.2656284, "Latitude": 47.8586205 },
148
+ { "ID": "69", "Longitude": 4.6859896, "Latitude": 45.8714754 },
149
+ { "ID": "70", "Longitude": 6.1388571, "Latitude": 47.5904191 },
150
+ { "ID": "71", "Longitude": 4.6394021, "Latitude": 46.5951234 },
151
+ { "ID": "72", "Longitude": 0.1947322, "Latitude": 48.0041421 },
152
+ { "ID": "73", "Longitude": 6.4662232, "Latitude": 45.4956055 },
153
+ { "ID": "74", "Longitude": 6.3609606, "Latitude": 46.1045902 },
154
+ { "ID": "75", "Longitude": 2.3416082, "Latitude": 48.8626759 },
155
+ { "ID": "76", "Longitude": 1.025579, "Latitude": 49.6862911 },
156
+ { "ID": "77", "Longitude": 2.8977309, "Latitude": 48.5957831 },
157
+ { "ID": "78", "Longitude": 1.8080138, "Latitude": 48.7831982 },
158
+ { "ID": "79", "Longitude": -0.3159014, "Latitude": 46.5490257 },
159
+ { "ID": "80", "Longitude": 2.3380595, "Latitude": 49.9783317 },
160
+ { "ID": "81", "Longitude": 2.2072751, "Latitude": 43.8524305 },
161
+ { "ID": "82", "Longitude": 1.2649374, "Latitude": 44.1254902 },
162
+ { "ID": "83", "Longitude": 6.1486127, "Latitude": 43.5007903 },
163
+ { "ID": "84", "Longitude": 5.065418, "Latitude": 44.0001599 },
164
+ { "ID": "85", "Longitude": -1.3956692, "Latitude": 46.5929102 },
165
+ { "ID": "86", "Longitude": 0.4953679, "Latitude": 46.5719095 },
166
+ { "ID": "87", "Longitude": 1.2500647, "Latitude": 45.9018644 },
167
+ { "ID": "88", "Longitude": 6.349702, "Latitude": 48.1770451 },
168
+ { "ID": "89", "Longitude": 3.5634078, "Latitude": 47.8474664 },
169
+ { "ID": "90", "Longitude": 6.9498114, "Latitude": 47.6184394 },
170
+ { "ID": "91", "Longitude": 2.2714555, "Latitude": 48.5203114 },
171
+ { "ID": "92", "Longitude": 2.2407148, "Latitude": 48.835321 },
172
+ { "ID": "93", "Longitude": 2.4811577, "Latitude": 48.9008719 },
173
+ { "ID": "94", "Longitude": 2.4549766, "Latitude": 48.7832368 },
174
+ { "ID": "95", "Longitude": 2.1802056, "Latitude": 49.076488 },
175
+ { "ID": "974", "Longitude": 55.536384, "Latitude": -21.115141 },
176
+ { "ID": "973", "Longitude": -53.125782, "Latitude": 3.933889 },
177
+ { "ID": "972", "Longitude": -61.024174, "Latitude": 14.641528 },
178
+ { "ID": "971", "Longitude": -61.551, "Latitude": 16.265 }
179
+ ]
180
+ longLat = pd.DataFrame(ListCentroids)
181
+ return longLat
182
+
183
  def modele(document):
184
  match document:
185
  case "Note de composante sectorielle":
 
375
  df_experience = finals_df.groupby('experienceLibelle').size().reset_index(name='obs')
376
  fig_experience = px.pie(df_experience, names='experienceLibelle', width=800, height=800, values='obs', color='obs', 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,color="RebeccaPurple"))
377
 
378
+ res = requests.get(
379
+ "https://raw.githubusercontent.com/codeforgermany/click_that_hood/main/public/data/spain-provinces.geojson"
380
+ )
381
+ ######## localisation ########
382
+ df_localisation = localisation_df.groupby('lieuTravail').size().reset_index(name='obs')
383
+ df_localisation = df_localisation.sort_values(by=['lieuTravail'])
384
+ df_localisation['longitude'] = df_localisation['lieuTravail']
385
+ df_localisation['latitude'] = df_localisation['lieuTravail']
386
+
387
+ df_localisation["longitude"] = df_localisation['longitude'].apply(lambda x:longLat.loc[longLat['ID'] == x, 'Longitude'].iloc[0])
388
+ df_localisation["latitude"] = df_localisation['latitude'].apply(lambda x:longLat.loc[longLat['ID'] == x, 'Latitude'].iloc[0])
389
+
390
+ fig_localisation = px.scatter_mapbox(df_localisation, lat="latitude", lon="longitude", height=600,hover_name="lieuTravail", size="obs").update_layout(
391
+ mapbox={
392
+ "style": "carto-positron",
393
+ "center": {"lon": 2, "lat" : 47},
394
+ "zoom": 4.5,
395
+ "layers": [
396
+ {
397
+ "source": res.json(),
398
+ "type": "line",
399
+ "color": "green",
400
+ "line": {"width": 0},
401
+ }
402
+ ],
403
+ }
404
+ )
405
+
406
+ elements.append(cl.Plotly(name="chart_intitule", figure=fig_intitule, display="inline", size="large"))
407
+ elements.append(cl.Plotly(name="chart_contrat", figure=fig_contrat, display="inline", size="large"))
408
+ elements.append(cl.Plotly(name="chart_competences", figure=fig_competences, display="inline", size="large"))
409
+ elements.append(cl.Plotly(name="chart_transversales", figure=fig_transversales, display="inline", size="large"))
410
+ elements.append(cl.Plotly(name="chart_formations", figure=fig_formations, display="inline", size="large"))
411
+ elements.append(cl.Plotly(name="chart_experience", figure=fig_experience, display="inline", size="large"))
412
+ elements.append(cl.Plotly(name="chart_secteur", figure=fig_secteur, display="inline", size="large"))
413
+ elements.append(cl.Plotly(name="chart_localisation", figure=fig_localisation, display="inline", size="large"))
414
+
415
+ await cl.Message(content="Datavisualisation du marché de l'emploi", elements=elements).send()
416
  await action.remove()
417
 
418
  @cl.action_callback("saveMemory")