Update main.py
Browse files
main.py
CHANGED
|
@@ -184,7 +184,94 @@ async def on_action(action):
|
|
| 184 |
).send()
|
| 185 |
await action.remove()
|
| 186 |
|
| 187 |
-
@cl.action_callback("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
async def on_action(action):
|
| 189 |
buffer = cl.user_session.get("saveMemory")
|
| 190 |
cl.user_session.set("saveMemory", buffer + action.value)
|
|
@@ -809,7 +896,6 @@ async def construction_FCS(romeListArray,settings):
|
|
| 809 |
|
| 810 |
@literal_client.step(type="run")
|
| 811 |
async def construction_NCS(romeListArray):
|
| 812 |
-
print(romeListArray[0])
|
| 813 |
context = await contexte(romeListArray)
|
| 814 |
emploisST = cl.user_session.get("EmploiST")
|
| 815 |
memory = ConversationBufferMemory(return_messages=True)
|
|
@@ -852,6 +938,11 @@ async def construction_NCS(romeListArray):
|
|
| 852 |
)
|
| 853 |
await cl.Message(author="Datapcc : 🌐🌐🌐",content="👨💼 Source Pôle Emploi : " + listEmplois_name, elements=text_elements).send()
|
| 854 |
await cl.sleep(2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 855 |
if romeListArray[0].find(',') != -1:
|
| 856 |
codeArray = romeListArray[0].split(',')
|
| 857 |
ficheMetiers = []
|
|
|
|
| 184 |
).send()
|
| 185 |
await action.remove()
|
| 186 |
|
| 187 |
+
@cl.action_callback("datavizEmploi")
|
| 188 |
+
async def on_action(action):
|
| 189 |
+
todayDate = datetime.datetime.today()
|
| 190 |
+
month, year = (todayDate.month-1, todayDate.year) if todayDate.month != 1 else (12, todayDate.year-1)
|
| 191 |
+
start_dt = todayDate.replace(day=1, month=month, year=year)
|
| 192 |
+
end_dt = datetime.datetime.today()
|
| 193 |
+
arraydataframe = []
|
| 194 |
+
arrayfirstdataframe = []
|
| 195 |
+
arraylocalisationdataframe = []
|
| 196 |
+
results = []
|
| 197 |
+
count = 0
|
| 198 |
+
listrome = action.value
|
| 199 |
+
arrayrome = listrome.split(',')
|
| 200 |
+
for k in arrayrome:
|
| 201 |
+
params = {"motsCles": k,'minCreationDate': dt_to_str_iso(start_dt),'maxCreationDate': dt_to_str_iso(end_dt),'range':'0-149'}
|
| 202 |
+
search_on_big_data = client.search(params=params)
|
| 203 |
+
results += search_on_big_data["resultats"]
|
| 204 |
+
results_df = pd.DataFrame(results)
|
| 205 |
+
if results_df.empty == False:
|
| 206 |
+
count = count + 1
|
| 207 |
+
finals = results_df[['intitule','typeContratLibelle','experienceLibelle','competences','qualitesProfessionnelles','salaire','lieuTravail','formations']]
|
| 208 |
+
finals["lieuTravail"] = finals["lieuTravail"].apply(lambda x: np.array(x)).apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
|
| 209 |
+
finals_df = finals
|
| 210 |
+
finals_df.dropna(subset=['qualitesProfessionnelles','formations','competences'], inplace=True)
|
| 211 |
+
finals_df["competences"] = finals_df["competences"].apply(lambda x:[str(e['libelle']) for e in x]).apply(lambda x:'; '.join(map(str, x)))
|
| 212 |
+
finals_df["qualitesProfessionnelles"] = finals_df["qualitesProfessionnelles"].apply(lambda x:[str(e['libelle']) + ": " + str(e['description']) for e in x]).apply(lambda x:'; '.join(map(str, x)))
|
| 213 |
+
finals_df["formations"] = finals_df["formations"].apply(lambda x:[str(e['niveauLibelle']) for e in x]).apply(lambda x:'; '.join(map(str, x)))
|
| 214 |
+
finals_df = finals_df.sort_values(by=['lieuTravail'])
|
| 215 |
+
finals_localisation = results_df[['lieuTravail']]
|
| 216 |
+
finals_localisation["lieuTravail"] = finals_localisation["lieuTravail"].apply(lambda x: np.array(x)).apply(lambda x: x['libelle']).apply(lambda x: x[0:3]).apply(lambda x: x.strip())
|
| 217 |
+
finals_localisation.drop(finals_localisation[finals_localisation['lieuTravail'] == 'Fra'].index, inplace = True)
|
| 218 |
+
finals_localisation.drop(finals_localisation[finals_localisation['lieuTravail'] == 'FRA'].index, inplace = True)
|
| 219 |
+
finals_localisation.drop(finals_localisation[finals_localisation['lieuTravail'] == 'Ile'].index, inplace = True)
|
| 220 |
+
finals_localisation.drop(finals_localisation[finals_localisation['lieuTravail'] == 'Mar'].index, inplace = True)
|
| 221 |
+
finals_localisation.drop(finals_localisation[finals_localisation['lieuTravail'] == 'Bou'].index, inplace = True)
|
| 222 |
+
finals_localisation.drop(finals_localisation[finals_localisation['lieuTravail'] == '976'].index, inplace = True)
|
| 223 |
+
arraylocalisationdataframe.append(finals_localisation)
|
| 224 |
+
arrayfirstdataframe.append(results_df)
|
| 225 |
+
if len(finals_df) != 0:
|
| 226 |
+
arraydataframe.append(finals_df)
|
| 227 |
+
first_df = pd.concat(arrayfirstdataframe)
|
| 228 |
+
finals_df = pd.concat(arraydataframe)
|
| 229 |
+
localisation_df = pd.concat(arraylocalisationdataframe)
|
| 230 |
+
|
| 231 |
+
######## Emplois ########
|
| 232 |
+
df_intitule = first_df.groupby('intitule').size().reset_index(name='obs')
|
| 233 |
+
df_intitule = df_intitule.sort_values(by=['obs'])
|
| 234 |
+
df_intitule = df_intitule.iloc[-25:]
|
| 235 |
+
fig_intitule = px.bar(df_intitule, x='obs', y='intitule', width=800, height=600, orientation='h', color='obs', title="Les principaux emplois", labels={'obs':'nombre'}, color_continuous_scale="Teal", text_auto=True).update_layout(font=dict(size=10,color="RebeccaPurple"),autosize=True).update_traces(hovertemplate=df_intitule["intitule"] + ' <br>Nombre : %{x}', y=[y[:100] + "..." for y in df_intitule["intitule"]], showlegend=False)
|
| 236 |
+
|
| 237 |
+
######## Types de contrat ########
|
| 238 |
+
df_contrat = first_df.groupby('typeContratLibelle').size().reset_index(name='obs')
|
| 239 |
+
fig_contrat = px.pie(df_contrat, names='typeContratLibelle', width=800, height=800, values='obs', color='obs', 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,color="RebeccaPurple"))
|
| 240 |
+
|
| 241 |
+
df_secteur = first_df.groupby('secteurActiviteLibelle').size().reset_index(name='obs')
|
| 242 |
+
df_secteur = df_secteur.sort_values(by=['obs'])
|
| 243 |
+
df_secteur = df_secteur.iloc[-25:]
|
| 244 |
+
fig_secteur = px.bar(df_secteur, x='obs', y='secteurActiviteLibelle', width=800, height=600, orientation='h', color='obs', title="Les principaux secteurs d'activités", labels={'obs':'nombre'}, color_continuous_scale="Teal", text_auto=True).update_layout(font=dict(size=10,color="RebeccaPurple"),autosize=True).update_traces(hovertemplate=df_secteur["secteurActiviteLibelle"] + ' <br>Nombre : %{x}', y=[y[:100] + "..." for y in df_secteur["secteurActiviteLibelle"]], showlegend=False)
|
| 245 |
+
|
| 246 |
+
######## Compétences professionnelles ########
|
| 247 |
+
df1 = finals_df
|
| 248 |
+
df1['competences'] = finals_df['competences'].str.split(';')
|
| 249 |
+
df2 = df1.explode('competences')
|
| 250 |
+
df2 = df2.groupby('competences').size().reset_index(name='obs')
|
| 251 |
+
df2 = df2.sort_values(by=['obs'])
|
| 252 |
+
df2 = df2.iloc[-20:]
|
| 253 |
+
fig_competences = px.bar(df2, x='obs', y='competences', width=800, height=550, orientation='h', color='obs', title="Les principales compétences professionnelles", labels={'obs':'nombre'}, color_continuous_scale="Teal", text_auto=True).update_layout(font=dict(size=10,color="RebeccaPurple"),autosize=True).update_traces(hovertemplate=df2["competences"] + ' <br>Nombre : %{x}', y=[y[:100] + "..." for y in df2['competences']], showlegend=False)
|
| 254 |
+
|
| 255 |
+
######## Compétences transversales ########
|
| 256 |
+
df_transversales = finals_df
|
| 257 |
+
df_transversales['qualitesProfessionnelles'] = finals_df['qualitesProfessionnelles'].str.split(';')
|
| 258 |
+
df_comptransversales = df_transversales.explode('qualitesProfessionnelles')
|
| 259 |
+
df_comptransversales = df_comptransversales.groupby('qualitesProfessionnelles').size().reset_index(name='obs')
|
| 260 |
+
df_comptransversales = df_comptransversales.sort_values(by=['obs'])
|
| 261 |
+
df_comptransversales = df_comptransversales.iloc[-20:]
|
| 262 |
+
fig_transversales = px.bar(df_comptransversales, x='obs', y='qualitesProfessionnelles', width=800, height=550, orientation='h', color='obs', title="Les principales compétences transversales", labels={'obs':'nombre'}, color_continuous_scale="Teal", text_auto=True).update_layout(font=dict(size=10,color="RebeccaPurple"),autosize=True).update_traces(hovertemplate=df_comptransversales["qualitesProfessionnelles"] + ' <br>Nombre : %{x}', y=[y[:100] + "..." for y in df_comptransversales["qualitesProfessionnelles"]], showlegend=False)
|
| 263 |
+
|
| 264 |
+
######## Niveaux de qualification ########
|
| 265 |
+
df_formations = finals_df.groupby('formations').size().reset_index(name='obs')
|
| 266 |
+
fig_formations = px.pie(df_formations, names='formations', width=800, height=800, values='obs', color='obs', title="Les niveaux de qualification", 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"))
|
| 267 |
+
|
| 268 |
+
######## Expériences professionnelles ########
|
| 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")
|
| 275 |
async def on_action(action):
|
| 276 |
buffer = cl.user_session.get("saveMemory")
|
| 277 |
cl.user_session.set("saveMemory", buffer + action.value)
|
|
|
|
| 896 |
|
| 897 |
@literal_client.step(type="run")
|
| 898 |
async def construction_NCS(romeListArray):
|
|
|
|
| 899 |
context = await contexte(romeListArray)
|
| 900 |
emploisST = cl.user_session.get("EmploiST")
|
| 901 |
memory = ConversationBufferMemory(return_messages=True)
|
|
|
|
| 938 |
)
|
| 939 |
await cl.Message(author="Datapcc : 🌐🌐🌐",content="👨💼 Source Pôle Emploi : " + listEmplois_name, elements=text_elements).send()
|
| 940 |
await cl.sleep(2)
|
| 941 |
+
datavizEmploi = [
|
| 942 |
+
cl.Action(name="datavizEmploi", value=romeListArray[0], description="Afficher la datavisualisation du marché de l'emploi")
|
| 943 |
+
]
|
| 944 |
+
await cl.Message(author="Datapcc : 🌐🌐🌐",content="📊 Afficher la datavisualisation du marché de l'emploi", actions=datavizEmploi).send()
|
| 945 |
+
await cl.sleep(2)
|
| 946 |
if romeListArray[0].find(',') != -1:
|
| 947 |
codeArray = romeListArray[0].split(',')
|
| 948 |
ficheMetiers = []
|