Skip to content

Commit a558314

Browse files
committed
CLN: Move _constructor checks to PandasObject base
1 parent 8468b13 commit a558314

File tree

6 files changed

+5
-24
lines changed

6 files changed

+5
-24
lines changed

pandas/core/base.py

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ def __repr__(self):
4242
class PandasObject(StringMixin):
4343
"""baseclass for various pandas objects"""
4444

45+
@property
46+
def _constructor(self):
47+
"""class constructor (for this class it's just `__class__`"""
48+
return self.__class__
49+
4550
def __unicode__(self):
4651
"""
4752
Return a string representation for a particular object.

pandas/core/frame.py

-4
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,6 @@ def _verbose_info(self, value):
584584
def axes(self):
585585
return [self.index, self.columns]
586586

587-
@property
588-
def _constructor(self):
589-
return self.__class__
590-
591587
@property
592588
def shape(self):
593589
return (len(self.index), len(self.columns))

pandas/core/generic.py

-4
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,6 @@ def astype(self, dtype, copy = True, raise_on_error = True):
633633
mgr = self._data.astype(dtype, copy = copy, raise_on_error = raise_on_error)
634634
return self._constructor(mgr)
635635

636-
@property
637-
def _constructor(self):
638-
return NDFrame
639-
640636
@property
641637
def axes(self):
642638
return self._data.axes

pandas/core/index.py

-8
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,6 @@ def _set_names(self, values):
208208

209209
names = property(fset=_set_names, fget=_get_names)
210210

211-
@property
212-
def _constructor(self):
213-
return Index
214-
215211
@property
216212
def _has_complex_internals(self):
217213
# to disable groupby tricks in MultiIndex
@@ -1379,10 +1375,6 @@ def __new__(cls, data, dtype=None, copy=False, name=None):
13791375
def inferred_type(self):
13801376
return 'integer'
13811377

1382-
@property
1383-
def _constructor(self):
1384-
return Int64Index
1385-
13861378
@property
13871379
def asi8(self):
13881380
# do not cache or you'll create a memory leak

pandas/core/panel.py

-4
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,6 @@ class Panel(NDFrame):
186186
major_axis = lib.AxisProperty(1)
187187
minor_axis = lib.AxisProperty(2)
188188

189-
@property
190-
def _constructor(self):
191-
return type(self)
192-
193189
# return the type of the slice constructor
194190
_constructor_sliced = DataFrame
195191

pandas/core/series.py

-4
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,6 @@ def __init__(self, data=None, index=None, dtype=None, name=None,
519519
copy=False):
520520
pass
521521

522-
@property
523-
def _constructor(self):
524-
return Series
525-
526522
@property
527523
def _can_hold_na(self):
528524
return not is_integer_dtype(self.dtype)

0 commit comments

Comments
 (0)