Répertorier les performances des intersectionsVoici un
question pour tous les assistants JSL.
j'ai du texte
données que j'ai besoin de regrouper de différentes manières.
style="">
Mon tableau ressemble à ceci :
style="font-weight: bold; text-decoration: underline; font-family: monospace;">Mon
Catégorie de valeur 1
Catégorie 2 Catégorie 3
style="font-family: monospace;">
AA
1
1
0
style="font-family: monospace;">
BB
0
1
0
style="font-family: monospace;">
CC
1
0
0
style="font-family: monospace;">
JJ
0
1
0
style="font-family: monospace;">
EE
1
0
0
style="font-family: monospace;">
FF
0
0
0
style="font-family: monospace;">
AA
1
1
0
style="font-family: monospace;">
BB
0
1
0
style="font-family: monospace;">
GG
0
0
0
style="font-family: monospace;">
HH
0
0
1
style="font-family: monospace;">
MM
0
1
1
La catégorie
les colonnes me permettent de regrouper les données de différentes manières.
style=""> le
les catégories pour cet exemple proviennent du
listes suivantes :
style="font-size: 10pt; font-family: "Courier New"; color: black;">Catégorie
1
style="font-size: 10pt; font-family: "Courier New"; color: navy;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
{
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"AA"
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"CC"
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"EE"
style="font-size: 10pt; font-family: "Courier New"; color: black;">}
style="font-size: 10pt; font-family: "Courier New"; color: navy;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">Catégorie
2
style="font-size: 10pt; font-family: "Courier New"; color: navy;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
{
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"AA"
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"BB"
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"DD"
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"MM"
style="font-size: 10pt; font-family: "Courier New"; color: black;">}
style="font-size: 10pt; font-family: "Courier New"; color: navy;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: black;">Catégorie
3
style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: navy;">=
style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: black;">
{
style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: purple;">"KK"
style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: black;">
style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: purple;">"MM"
style="font-size : 10pt ; line-height : 115% ; font-family : "Courier New" ; color : black ;">}
style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: navy;">;
Si vous êtes
me demandant pourquoi je n'ajoute pas simplement une colonne de catégorie,
c'est parce qu'il peut y avoir
chevauchement dans les listes de catégories.
Ainsi je
besoin d'une colonne distincte pour chaque catégorie.
Si une valeur
dans le MaValeur
la colonne correspond à un
valeur dans une liste de catégories, alors la colonne de catégorie est 1, sinon elle
est 0.
Cela me permet d'effectuer rapidement des analyses séparées des données
correspondant à chaque catégorie.
Mon problème
est celui de la performance lors du calcul des colonnes de catégorie.
style=""> C'est
pas mal pour les petites tables (10 000 lignes, 3
catégories, petites listes de catégories).
style="">
Cependant ça s'enlise
pour les ensembles de données plus volumineux (300 000 lignes, 200
catégories, grandes listes de catégories).
style=""> Quelques
des listes de catégories peut être assez volumineux (valeurs 2000).
En gros je
besoin d'un moyen rapide de faire une sorte d'intersection de liste entre les données
dans le MaValeur
colonne et les données de chaque
liste des catégories.
C'est un très simple
exemple, mais il illustre le concept.
Ici se trouve le
logique que j'utilise pour une catégorie.
style=""> le
possibilité de trouver des correspondances entre une liste et une colonne en utilisant
style="">SÉLECTIONNER O
est très puissant.
Si cela peut être accéléré d'une manière ou d'une autre
J'aimerais savoir comment !
style="font-size: 10pt; font-family: "Courier New"; color: black;">one_category
style="font-size: 10pt; font-family: "Courier New"; color: navy;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Catégorie
1"
style="font-size: 10pt; font-family: "Courier New"; color: navy;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">category_list
style="font-size: 10pt; font-family: "Courier New"; color: navy;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
{
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"AA"
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"CC"
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"EE"
style="font-size: 10pt; font-family: "Courier New"; color: black;">}
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">nr
style="font-size: 10pt; font-family: "Courier New"; color: navy;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">nrows
style="font-size: 10pt; font-family: "Courier New"; color: black;">(
style="font-size: 10pt; font-family: "Courier New"; color: black;">dt )
style="font-size: 10pt; font-family: "Courier New"; color: navy;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">col_zeroes
style="font-size: 10pt; font-family: "Courier New"; color: navy;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">j
style="font-size: 10pt; font-family: "Courier New"; color: black;">(
style="font-size: 10pt; font-family: "Courier New"; color: black;">nr
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: teal;">1
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: teal;">0
style="font-size: 10pt; font-family: "Courier New"; color: black;">)
style="font-size: 10pt; font-family: "Courier New"; color: navy;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: green;">//
Ajouter la colonne catégorie
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">dt
style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">new
colonne
style="font-size: 10pt; font-family: "Courier New"; color: black;">(
style="font-size: 10pt; font-family: "Courier New"; color: black;">one_category
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
numérique )
style="font-size: 10pt; font-family: "Courier New"; color: navy;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">colonne
style="font-size: 10pt; font-family: "Courier New"; color: black;">(
style="font-size: 10pt; font-family: "Courier New"; color: black;">dt
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
une_catégorie )
style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<
style="font-size: 10pt; font-family: "Courier New"; color: black;">
cacher (
style="font-size: 10pt; font-family: "Courier New"; color: teal;">1
style="font-size: 10pt; font-family: "Courier New"; color: black;">)
style="font-size: 10pt; font-family: "Courier New"; color: navy;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: green;">//
Définir la colonne entière pour être
des zéros au départ
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">colonne
style="font-size: 10pt; font-family: "Courier New"; color: black;">(
style="font-size: 10pt; font-family: "Courier New"; color: black;">dt
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
une_catégorie )
style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<
style="font-size: 10pt; font-family: "Courier New"; color: black;">
valeurs ( col_zéroes [
style="font-size: 10pt; font-family: "Courier New"; color: teal;">0
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: teal;">1
style="font-size: 10pt; font-family: "Courier New"; color: black;">])
style="font-size: 10pt; font-family: "Courier New"; color: navy;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: green;">//
Sélectionnez toutes les lignes avec des valeurs
correspondant à cette catégorie
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">dt
style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<
style="font-size: 10pt; font-family: "Courier New"; color: black;">
sélectionnez où (
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">contient
style="font-size: 10pt; font-family: "Courier New"; color: black;">(
style="font-size: 10pt; font-family: "Courier New"; color: black;">category_list
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: navy;">:
style="font-size: 10pt; font-family: "Courier New"; color: black;">My
Valeur ))
style="font-size: 10pt; font-family: "Courier New"; color: navy;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: green;">//
Obtenir une liste des sélectionnés
Lignes
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">one_cat_rows
style="font-size: 10pt; font-family: "Courier New"; color: navy;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
dt
style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<
style="font-size: 10pt; font-family: "Courier New"; color: black;">
être sélectionné
Lignes ()
style="font-size: 10pt; font-family: "Courier New"; color: navy;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: green;">//
Définissez toutes les lignes correspondantes sur 1 pour
cette catégorie
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if
style="font-size: 10pt; font-family: "Courier New"; color: black;">
(
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">nrows
style="font-size: 10pt; font-family: "Courier New"; color: black;">(
style="font-size: 10pt; font-family: "Courier New"; color: black;">one_cat_rows )
style="font-size: 10pt; font-family: "Courier New"; color: navy;">>
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: teal;">0
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">colonne
style="font-size: 10pt; font-family: "Courier New"; color: black;">(
style="font-size: 10pt; font-family: "Courier New"; color: black;">dt
style="font-size: 10pt; font-family: "Courier New"; color: navy;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
une_catégorie )[ one_cat_rows ]
style="font-size: 10pt; font-family: "Courier New"; color: navy;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: teal;">1
style="font-size: 10pt; font-family: "Courier New"; color: navy;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: black;">)
style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: navy;">;