Skip to content
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

BUG: Series.getitem not falling back to positional for bool index #48662

Merged
merged 30 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8ad4ce9
BUG: Series.getitem not falling back to positional for bool index
phofl Sep 20, 2022
186a3d0
Update pandas/tests/series/indexing/test_getitem.py
phofl Sep 21, 2022
b3e977f
Fix build warning for use of `strdup` in ultrajson (#48369)
rgommers Sep 20, 2022
22a52c6
WEB: Update versions json to fix version switcher in the docs (#48655)
datapythonista Sep 20, 2022
4d07469
PERF: join/merge on subset of MultiIndex (#48611)
lukemanley Sep 20, 2022
c8ca83a
DOC: Update documentation for date_range(), bdate_range(), and interv…
gandhis1 Sep 20, 2022
dce4c73
TYP: tighten Axis (#48612)
twoertwein Sep 20, 2022
aa0fa52
BUG: Fix metadata propagation in df.corr and df.cov, GH28283 (#48616)
yuanx749 Sep 20, 2022
6c8390e
TST: add test case for PeriodIndex in HDFStore(GH7796) (#48618)
paradox-lab Sep 20, 2022
f38383f
Add OpenSSF Scorecards GitHub Action (#48570)
pnacht Sep 20, 2022
b9ec72b
ENH: move an exception and add a prehook to check for exception place…
dataxerik Sep 20, 2022
1294474
REGR: TextIOWrapper raising an error in read_csv (#48651)
twoertwein Sep 20, 2022
89a433e
Fix scorecard.yml workflow (#48668)
pnacht Sep 20, 2022
70f5f89
BUG: DatetimeIndex ignoring explicit tz=None (#48659)
jbrockmendel Sep 21, 2022
84f7ddb
Corrected pd.merge indicator type hint (#48677)
PabloRuizCuevas Sep 21, 2022
6a36027
DOC: Document default value for options.display.max_cols when not run…
tmoschou Sep 21, 2022
2e4bf41
ENH: DTA/TDA add datetimelike scalar with mismatched reso (#48669)
jbrockmendel Sep 21, 2022
c3571e6
REF: support reso in remaining tslibs helpers (#48661)
jbrockmendel Sep 21, 2022
48dab82
PERF: Avoid fragmentation of DataFrame in read_sas (#48603)
phofl Sep 21, 2022
4396e8c
DOC: Add deprecation infos to deprecated functions (#48599)
phofl Sep 21, 2022
0821c9c
BLD: Build wheels using cibuildwheel (#48283)
lithomas1 Sep 21, 2022
c6b0f0f
REGR: Performance decrease in factorize (#48620)
rhshadrach Sep 22, 2022
359cc5c
TYP: type all arguments with str default values (#48508)
twoertwein Sep 22, 2022
34e2b21
TST: Catch more pyarrow PerformanceWarnings (#48699)
mroeschke Sep 22, 2022
0a9f5ac
REGR: to_hdf raising AssertionError with boolean index (#48696)
phofl Sep 22, 2022
a746068
REGR: Regression in DataFrame.loc when setting df with all True index…
phofl Sep 22, 2022
7123154
BUG: pivot_table raising for nullable dtype and margins (#48714)
phofl Sep 22, 2022
e30a3d8
TST: Address MPL 3.6 deprecation warnings (#48695)
mroeschke Sep 22, 2022
f8c7df6
Merge remote-tracking branch 'upstream/main' into 48653
phofl Sep 22, 2022
2729963
Merge remote-tracking branch 'upstream/main' into 48653
phofl Sep 23, 2022
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
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.5.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Fixed regressions

Bug fixes
~~~~~~~~~
- Bug in :meth:`Series.__getitem__` not falling back to positional for integer keys and boolean :class:`Index` (:issue:`48653`)
- Bug in :meth:`DataFrame.to_hdf` raising ``AssertionError`` with boolean index (:issue:`48667`)
- Bug in :meth:`DataFrame.pivot_table` raising unexpected ``FutureWarning`` when setting datetime column as index (:issue:`48683`)
-
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6017,7 +6017,7 @@ def _should_fallback_to_positional(self) -> bool:
"""
Should an integer key be treated as positional?
"""
return not self.holds_integer() and not self.is_boolean()
return not self.holds_integer()

def _get_values_for_loc(self, series: Series, loc, key):
"""
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/series/indexing/test_getitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ def test_getitem_str_with_timedeltaindex(self):
with pytest.raises(KeyError, match=msg):
ser["50 days"]

def test_getitem_bool_index_positional(self):
# GH#48653
ser = Series({True: 1, False: 0})
result = ser[0]
assert result == 1


class TestSeriesGetitemSlices:
def test_getitem_partial_str_slice_with_datetimeindex(self):
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/series/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ def test_loc_setitem_nested_data_enlargement():
tm.assert_series_equal(ser, expected)


def test_getitem_bool_int_key():
# GH#48653
ser = Series({True: 1, False: 0})
with pytest.raises(KeyError, match="0"):
ser.loc[0]


class TestDeprecatedIndexers:
@pytest.mark.parametrize("key", [{1}, {1: 1}])
def test_getitem_dict_and_set_deprecated(self, key):
Expand Down