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/25151 below:

Implement sort=True for Index setops · Issue #25151 · pandas-dev/pandas · GitHub

#25063 made the 0.24.x sort=True behavior be enabled by sort=None. This allows us to use sort=True to mean "always sort".

So rather than raising

In [1]: import pandas as pd

In [2]: idx = pd.Index([1, 0])

In [3]: idx.union(idx, sort=True)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-92d6bafc02d6> in <module>
----> 1 idx.union(idx, sort=True)

~/sandbox/pandas/pandas/core/indexes/base.py in union(self, other, sort)
   2319         Index(['a', 'b', 'c', 'd', 1, 2, 3, 4], dtype='object')
   2320         """
-> 2321         self._validate_sort_keyword(sort)
   2322         self._assert_can_do_setop(other)
   2323

~/sandbox/pandas/pandas/core/indexes/base.py in _validate_sort_keyword(self, sort)
   2263         if sort not in [None, False]:
   2264             raise ValueError(
-> 2265                 "The 'sort' keyword only takes the values of "
   2266                 f"None or False; {sort} was passed."
   2267             )

ValueError: The 'sort' keyword only takes the values of None or False; True was passed.

We would instead return

Int64Index([0, 1], dtype='int64')

This is a (hopefully) exhaustive list of special cases not sorted when sort=None.


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