8000 Revert set_index inspection/error handling for 0.24.1 by h-vetinari · Pull Request #25085 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

Revert set_index inspection/error handling for 0.24.1 #25085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Feb 3, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
31dcbb7
DOC: Minor what's new fix (#24933)
rth Jan 26, 2019
84056c5
Backport PR #24916: BUG-24212 fix regression in #24897 (#24951)
meeseeksmachine Jan 26, 2019
e22a6c8
Revert "Backport PR #24916: BUG-24212 fix regression in #24897 (#24951)"
jorisvandenbossche Jan 28, 2019
638ac19
Backport PR #24965: Fixed itertuples usage in to_dict (#24978)
meeseeksmachine Jan 28, 2019
72dc33f
Backport PR #24989: DOC: Document breaking change to read_csv (#24996)
meeseeksmachine Jan 29, 2019
fd1c66c
Backport PR #24964: DEPR: Fixed warning for implicit registration (#2…
meeseeksmachine Jan 29, 2019
d54c3a5
Backport PR #24973: fix for BUG: grouping with tz-aware: Values falls…
TomAugspurger Jan 29, 2019
e3cc0b1
Backport PR #24967: REGR: Preserve order by default in Index.differen…
meeseeksmachine Jan 30, 2019
c228597
Backport PR #24961: fix+test to_timedelta('NaT', box=False) (#25025)
meeseeksmachine Jan 30, 2019
7956533
Backport PR #25033: BUG: Fixed merging on tz-aware (#25041)
meeseeksmachine Jan 30, 2019
722bb79
Backport PR #24993: Test nested PandasArray (#25042)
meeseeksmachine Jan 30, 2019
e3634b1
Backport PR #25039: BUG: avoid usage in_qtconsole for recent IPython …
meeseeksmachine Jan 31, 2019
4f865c5
Backport PR #25024: REGR: fix read_sql delegation for queries on MySQ…
meeseeksmachine Jan 31, 2019
c21d32f
Backport PR #25069: REGR: rename_axis with None should remove axis na…
meeseeksmachine Feb 1, 2019
5cb622a
DOC: 0.24.1 whatsnew (#25027)
TomAugspurger Feb 1, 2019
c397839
Revert "DOC: update DF.set_index (#24762)"
h-vetinari Feb 1, 2019
4a211e9
Revert "API: better error-handling for df.set_index (#22486)"
h-vetinari Feb 1, 2019
103a092
Replace deprecated assert_raises_regex
h-vetinari Feb 1, 2019
8086f39
Re-migrate 0.24.0 extension (.txt -> .rst)
h-vetinari Feb 1, 2019
999295e
Re-add docstring clarifications
h-vetinari Feb 1, 2019
c24df00
Backport PR #25063: API: change Index set ops sort=True -> sort=None …
meeseeksmachine Feb 1, 2019
627b17a
trigger azure
TomAugspurger Feb 1, 2019
bc405ce
Backport PR #25084: DOC: Cleanup 0.24.1 whatsnew (#25086)
meeseeksmachine Feb 2, 2019
02db6ec
Backport PR #25026: DOC: Start 0.24.2.rst (#25073)
meeseeksmachine Feb 2, 2019
ff34d2e
trigger azure
TomAugspurger Feb 2, 2019
2aa800c
Merge remote-tracking branch 'upstream/0.24.x' into revert_set_index
h-vetinari Feb 3, 2019
330b343
Keep all tests from #24984; xfail where necessary
h-vetinari Feb 3, 2019
24a4df4
Merge remote-tracking branch 'origin/revert_set_index' into revert_se…
h-vetinari Feb 3, 2019
963a813
Remove stray debugging line
h-vetinari Feb 3, 2019
4db4849
Add whatsnew
h-vetinari Feb 3, 2019
8c913c2
Merge remote-tracking branch 'upstream/master' into h-vetinari-revert…
jorisvandenbossche Feb 3, 2019
5a6cc73
Merge remote-tracking branch 'upstream/master' into revert_set_index
h-vetinari Feb 3, 2019
ff62753
Re-add reverted 0.24.0 whatsnew
h-vetinari Feb 3, 2019
65c7880
Re-add handling for duplicate drops
h-vetinari Feb 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
Prev Previous commit
Next Next commit
Backport PR #24967: REGR: Preserve order by default in Index.differen…
…ce (#25013)
  • Loading branch information
meeseeksmachine authored and jreback committed Jan 30, 2019
commit e3cc0b18ea933613af27fefeb07431cc305030a7
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Fixed Regressions

- Bug in :meth:`DataFrame.itertuples` with ``records`` orient raising an ``AttributeError`` when the ``DataFrame`` contained more than 255 columns (:issue:`24939`)
- Bug in :meth:`DataFrame.itertuples` orient converting integer column names to strings prepended with an underscore (:issue:`24940`)
- Fixed regression in :class:`Index.intersection` incorrectly sorting the values by default (:issue:`24959`).

.. _whatsnew_0241.enhancements:

Expand Down
8 changes: 6 additions & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2333,7 +2333,7 @@ def union(self, other, sort=True):
def _wrap_setop_result(self, other, result):
return self._constructor(result, name=get_op_result_name(self, other))

def intersection(self, other, sort=True):
def intersection(self, other, sort=False):
"""
Form the intersection of two Index objects.

Expand All @@ -2342,11 +2342,15 @@ def intersection(self, other, sort=True):
Parameters
----------
other : Index or array-like
sort : bool, default True
sort : bool, default False
Sort the resulting index if possible

.. versionadded:: 0.24.0

.. versionchanged:: 0.24.1

Changed the default from ``True`` to ``False``.

Returns
-------
intersection : Index
Expand Down
10 changes: 9 additions & 1 deletion pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,14 +594,22 @@ def _wrap_setop_result(self, other, result):
name = get_op_result_name(self, other)
return self._shallow_copy(result, name=name, freq=None, tz=self.tz)

def intersection(self, other, sort=True):
def intersection(self, other, sort=False):
"""
Specialized intersection for DatetimeIndex objects. May be much faster
than Index.intersection

Parameters
----------
other : DatetimeIndex or array-like
sort : bool, default True
Sort the resulting index if possible.

.. versionadded:: 0.24.0

.. versionchanged:: 0.24.1

Changed the default from ``True`` to ``False``.

Returns
-------
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,8 @@ def equals(self, other):
def overlaps(self, other):
return self._data.overlaps(other)

def _setop(op_name):
def func(self, other, sort=True):
def _setop(op_name, sort=True):
def func(self, other, sort=sort):
other = self._as_like_interval_index(other)

# GH 19016: ensure set op will not return a prohibited dtype
Expand Down Expand Up @@ -1128,7 +1128,7 @@ def is_all_dates(self):
return False

union = _setop('union')
intersection = _setop('intersection')
intersection = _setop('intersection', sort=False)
difference = _setop('difference')
symmetric_difference = _setop('symmetric_difference')

Expand Down
6 changes: 5 additions & 1 deletion pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2910,7 +2910,7 @@ def union(self, other, sort=True):
return MultiIndex.from_arrays(lzip(*uniq_tuples), sortorder=0,
names=result_names)

def intersection(self, other, sort=True):
def intersection(self, other, sort=False):
"""
Form the intersection of two MultiIndex objects.

Expand All @@ -2922,6 +2922,10 @@ def intersection(self, other, sort=True):

.. versionadded:: 0.24.0

.. versionchanged:: 0.24.1

Changed the default from ``True`` to ``False``.

Returns
-------
Index
Expand Down
6 changes: 5 additions & 1 deletion pandas/core/indexes/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def equals(self, other):

return super(RangeIndex, self).equals(other)

def intersection(self, other, sort=True):
def intersection(self, other, sort=False):
"""
Form the intersection of two Index objects.

Expand All @@ -355,6 +355,10 @@ def intersection(self, other, sort=True):

.. versionadded:: 0.24.0

.. versionchanged:: 0.24.1

Changed the default from ``True`` to ``False``.

Returns
-------
intersection : Index
Expand Down
22 changes: 17 additions & 5 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,11 @@ def test_intersect_str_dates(self, sort):

assert len(result) == 0

def test_intersect_nosort(self):
result = pd.Index(['c', 'b', 'a']).intersection(['b', 'a'])
expected = pd.Index(['b', 'a'])
tm.assert_index_equal(result, expected)

@pytest.mark.parametrize("sort", [True, False])
def test_chained_union(self, sort):
# Chained unions handles names correctly
Expand Down Expand Up @@ -1595,20 +1600,27 @@ def test_drop_tuple(self, values, to_drop):
for drop_me in to_drop[1], [to_drop[1]]:
pytest.raises(KeyError, removed.drop, drop_me)

@pytest.mark.parametrize("method,expected", [
@pytest.mark.parametrize("method,expected,sort", [
('intersection', np.array([(1, 'A'), (2, 'A'), (1, 'B'), (2, 'B')],
dtype=[('num', int), ('let', 'a1')]),
False),

('intersection', np.array([(1, 'A'), (1, 'B'), (2, 'A'), (2, 'B')],
dtype=[('num', int), ('let', 'a1')])),
dtype=[('num', int), ('let', 'a1')]),
True),

('union', np.array([(1, 'A'), (1, 'B'), (1, 'C'), (2, 'A'), (2, 'B'),
(2, 'C')], dtype=[('num', int), ('let', 'a1')]))
(2, 'C')], dtype=[('num', int), ('let', 'a1')]),
True)
])
def test_tuple_union_bug(self, method, expected):
def test_tuple_union_bug(self, method, expected, sort):
index1 = Index(np.array([(1, 'A'), (2, 'A'), (1, 'B'), (2, 'B')],
dtype=[('num', int), ('let', 'a1')]))
index2 = Index(np.array([(1, 'A'), (2, 'A'), (1, 'B'),
(2, 'B'), (1, 'C'), (2, 'C')],
dtype=[('num', int), ('let', 'a1')]))

result = getattr(index1, method)(index2)
result = getattr(index1, method)(index2, sort=sort)
assert result.ndim == 1

expected = Index(expected)
Expand Down
0