This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
merged = pd.merge(df1, df2, on='C1', how='left') | |
# Grouping by 'C1' and checking for multiple occurrences | |
grouped = merged.groupby('C1') | |
# Creating the new DataFrame with custom values for multiple occurrences | |
df3 = pd.DataFrame(columns=merged.columns) | |
for name, group in grouped: | |
if len(group) > 1: | |
df3 = df3.append({col: 'multiple' if col == 'C2' else 'MULTIPLE' for col in merged.columns}, ignore_index=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# Texte initial | |
texte = 'prix\n100\nnombre\n2' | |
# Diviser le texte en lignes | |
lignes = texte.split('\n') | |
# Initialiser des listes vides pour stocker les données | |
colonnes = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Déclaration de la macro variable */ | |
%let date_sas = '01JAN2023'd; | |
/* Extraction de v1 */ | |
data _null_; | |
/* Conversion de la date en format numérique YYYYMM */ | |
v1 = year(&date_sas.) * 100 + month(&date_sas.); | |
call symputx('v1', v1); | |
run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Taux_Variation_MNE = | |
CALCULATE( | |
( | |
SUMX( | |
VALUES('PBI'[MNE]), | |
(CALCULATE(SUM('PBI'[Montant]), 'PBI'[Semestre] = 2) - | |
CALCULATE(SUM('PBI'[Montant]), 'PBI'[Semestre] = 1)) / | |
CALCULATE(SUM('PBI'[Montant]), 'PBI'[Semestre] = 1) | |
) | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Taux_Variation_Produit = | |
VAR Ventes_Semestre1 = CALCULATE(SUM('TableVentess'[Ventes]), 'TableVentess'[Semestre] = 1) | |
VAR Ventes_Semestre2 = CALCULATE(SUM('TableVentess'[Ventes]), 'TableVentess'[Semestre] = 2) | |
VAR Ventes_Produit = CALCULATE(SUM('TableVentess'[Ventes]), ALLEXCEPT('TableVentess', 'TableVentess'[Produit])) | |
RETURN | |
IF(ISBLANK(Ventes_Semestre1) || ISBLANK(Ventes_Semestre2) || Ventes_Semestre1 = 0, BLANK(), (Ventes_Semestre2 - Ventes_Semestre1) / Ventes_Produit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%macro CalculTrimestre(dateDebutTrimestre); | |
/* Format the dateDebutTrimestre variable as a date */ | |
%let dateDebutTrimestre = %sysfunc(inputn(&dateDebutTrimestre, date9.)); | |
/* Étape 1: Filtrer les clients dont l'anniversaire est dans le trimestre fourni */ | |
proc sql; | |
create table ClientsAnniversaire as | |
select * | |
from VotreTable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5.QtWidgets import QApplication, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QPushButton, QWidget, QLineEdit, QMessageBox, QLabel | |
class NestedDictManager(QApplication): | |
def __init__(self, original_data): | |
super(NestedDictManager, self).__init([]) | |
self.original_data = original_data.copy() | |
self.data = original_data.copy() | |
self.tree = QTreeWidget() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ipywidgets as widgets | |
from IPython.display import display | |
class NestedDictManagerJupyter: | |
def __init__(self, original_data): | |
self.original_data = original_data | |
self.data = original_data.copy() | |
self.accordion = widgets.Accordion(selected_index=None) | |
self.accordion.observe(self.update_selected_item, names='selected_index') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ipywidgets as widgets | |
from IPython.display import display | |
def update_nested_dict(nested_dict, keys, new_value): | |
current_dict = nested_dict | |
for key in keys[:-1]: | |
current_dict = current_dict[key] | |
current_dict[keys[-1]] = new_value | |
def display_and_update_widgets(nested_dict): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save the Streamlit code in a separate file, e.g., my_streamlit_app.py | |
# my_streamlit_app.py | |
import streamlit as st | |
def update_nested_dict(nested_dict, keys, new_value): | |
current_dict = nested_dict | |
for key in keys[:-1]: | |
current_dict = current_dict[key] | |
current_dict[keys[-1]] = new_value |
NewerOlder