Skip to content

Commit b342bbd

Browse files
committed
Merge branch 'main' into ref-localizer-2
2 parents eddacb3 + 48d5159 commit b342bbd

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

doc/source/whatsnew/v1.5.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ Indexing
394394
- Bug in :meth:`Series.mask` with ``inplace=True`` or setting values with a boolean mask with small integer dtypes incorrectly raising (:issue:`45750`)
395395
- Bug in :meth:`DataFrame.mask` with ``inplace=True`` and ``ExtensionDtype`` columns incorrectly raising (:issue:`45577`)
396396
- Bug in getting a column from a DataFrame with an object-dtype row index with datetime-like values: the resulting Series now preserves the exact object-dtype Index from the parent DataFrame (:issue:`42950`)
397+
- Bug in :meth:`DataFrame.__getattribute__` raising ``AttributeError`` if columns have ``"string"`` dtype (:issue:`46185`)
397398
- Bug in indexing on a :class:`DatetimeIndex` with a ``np.str_`` key incorrectly raising (:issue:`45580`)
398399
- Bug in :meth:`CategoricalIndex.get_indexer` when index contains ``NaN`` values, resulting in elements that are in target but not present in the index to be mapped to the index of the NaN element, instead of -1 (:issue:`45361`)
399400
- Bug in setting large integer values into :class:`Series` with ``float32`` or ``float16`` dtype incorrectly altering these values instead of coercing to ``float64`` dtype (:issue:`45844`)

pandas/core/indexes/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
is_object_dtype,
9898
is_scalar,
9999
is_signed_integer_dtype,
100+
is_string_dtype,
100101
is_unsigned_integer_dtype,
101102
needs_i8_conversion,
102103
pandas_dtype,
@@ -5276,7 +5277,7 @@ def _can_hold_identifiers_and_holds_name(self, name) -> bool:
52765277
52775278
https://github.com/pandas-dev/pandas/issues/19764
52785279
"""
5279-
if self.is_object() or self.is_categorical():
5280+
if self.is_object() or is_string_dtype(self.dtype) or self.is_categorical():
52805281
return name in self
52815282
return False
52825283

pandas/tests/dtypes/test_inference.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import itertools
1818
from numbers import Number
1919
import re
20+
import sys
2021

2122
import numpy as np
2223
import pytest
@@ -205,8 +206,14 @@ def foo():
205206
inference.is_list_like([])
206207
foo()
207208

208-
with tm.external_error_raised(RecursionError):
209-
foo()
209+
rec_limit = sys.getrecursionlimit()
210+
try:
211+
# Limit to avoid stack overflow on Windows CI
212+
sys.setrecursionlimit(100)
213+
with tm.external_error_raised(RecursionError):
214+
foo()
215+
finally:
216+
sys.setrecursionlimit(rec_limit)
210217

211218

212219
def test_is_list_like_iter_is_none():

pandas/tests/frame/indexing/test_getitem.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ def test_getitem_sparse_column_return_type_and_dtype(self):
7272
result = df.loc[:, "A"]
7373
tm.assert_series_equal(result, expected)
7474

75+
def test_getitem_string_columns(self):
76+
# GH#46185
77+
df = DataFrame([[1, 2]], columns=Index(["A", "B"], dtype="string"))
78+
result = df.A
79+
expected = df["A"]
80+
tm.assert_series_equal(result, expected)
81+
7582

7683
class TestGetitemListLike:
7784
def test_getitem_list_missing_key(self):

0 commit comments

Comments
 (0)