Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Calcul scientifique
avec Python
Voir le programme détaillé
Classe « MultiIndex »

Méthode pandas.MultiIndex.swaplevel

Signature de la méthode swaplevel

def swaplevel(self, i=-2, j=-1) -> 'MultiIndex' 

Description

help(MultiIndex.swaplevel)

Swap level i with level j.

Calling this method does not change the ordering of the values.

Parameters
----------
i : int, str, default -2
    First level of index to be swapped. Can pass level name as string.
    Type of parameters can be mixed.
j : int, str, default -1
    Second level of index to be swapped. Can pass level name as string.
    Type of parameters can be mixed.

Returns
-------
MultiIndex
    A new MultiIndex.

See Also
--------
Series.swaplevel : Swap levels i and j in a MultiIndex.
DataFrame.swaplevel : Swap levels i and j in a MultiIndex on a
    particular axis.

Examples
--------
>>> mi = pd.MultiIndex(levels=[['a', 'b'], ['bb', 'aa']],
...                    codes=[[0, 0, 1, 1], [0, 1, 0, 1]])
>>> mi
MultiIndex([('a', 'bb'),
            ('a', 'aa'),
            ('b', 'bb'),
            ('b', 'aa')],
           )
>>> mi.swaplevel(0, 1)
MultiIndex([('bb', 'a'),
            ('aa', 'a'),
            ('bb', 'b'),
            ('aa', 'b')],
           )


Vous êtes un professionnel et vous avez besoin d'une formation ? Mise en oeuvre d'IHM
avec Qt et PySide6
Voir le programme détaillé