A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/9444 below:

sort=False ignored in Series groupby on MultiIndex levels · Issue #9444 · pandas-dev/pandas · GitHub

Example:

import pandas
def geta():
    i = pandas.MultiIndex.from_tuples([(1, 2, 'a', 0),
                              (1, 2, 'a', 1),
                              (1, 1, 'b', 0),
                              (1, 1, 'b', 1),
                              (2, 1, 'b', 0),
                              (2, 1, 'b', 1)], names=['a', 'b', 'c', 'd'])
    a = pandas.Series([0, 1, 2, 3, 4, 5], index=i)
    return(a)

for dosort in [True, False]:
    a = geta()
    b = a.groupby(level=['a', 'b'], sort=dosort).first()
    a = None
    print('%s, sort=%s, \n%s' % (geta.__name__, dosort, b))

Output:

geta, sort=True,
a  b
1  1    2
   2    0
2  1    4
dtype: int64
geta, sort=False,
a  b
1  1    2
   2    0
2  1    4
dtype: int64

Also see: #9076
Possibly related to: #8868


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4