Skip to content

Commit 14bfddd

Browse files
committed
Merge pull request #6108 from jreback/str
API: Series.str wont' raise and now returns None (GH6106)
2 parents 71360af + b59d5d4 commit 14bfddd

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

pandas/core/generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class NDFrame(PandasObject):
7979
copy : boolean, default False
8080
"""
8181
_internal_names = ['_data', '_cacher', '_item_cache', '_cache',
82-
'is_copy', '_subtyp', '_index', '_default_kind',
82+
'is_copy', 'str', '_subtyp', '_index', '_default_kind',
8383
'_default_fill_value','__array_struct__','__array_interface__']
8484
_internal_names_set = set(_internal_names)
8585
_metadata = []
@@ -616,7 +616,7 @@ def equals(self, other):
616616
if not isinstance(other, self._constructor):
617617
return False
618618
return self._data.equals(other._data)
619-
619+
620620
#----------------------------------------------------------------------
621621
# Iteration
622622

pandas/src/properties.pyx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ cdef class cache_readonly(object):
2222

2323
cache = getattr(obj, '_cache', None)
2424
if cache is None:
25-
cache = obj._cache = {}
25+
try:
26+
cache = obj._cache = {}
27+
except (AttributeError):
28+
return
2629

2730
if PyDict_Contains(cache, self.name):
2831
# not necessary to Py_INCREF
@@ -40,10 +43,13 @@ cdef class cache_readonly(object):
4043
# Get the cache or set a default one if needed
4144
cache = getattr(obj, '_cache', None)
4245
if cache is None:
43-
cache = obj._cache = {}
46+
try:
47+
cache = obj._cache = {}
48+
except (AttributeError):
49+
return
4450

4551
PyDict_SetItem(cache, self.name, value)
46-
52+
4753
cdef class AxisProperty(object):
4854
cdef:
4955
Py_ssize_t axis

pandas/tests/test_strings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class TestStringMethods(tm.TestCase):
2929

3030
_multiprocess_can_split_ = True
3131

32+
def test_api(self):
33+
34+
# GH 6106
35+
self.assert_(Series.str is None)
36+
3237
def test_iter(self):
3338
# GH3638
3439
strs = 'google', 'wikimedia', 'wikipedia', 'wikitravel'

0 commit comments

Comments
 (0)