9
9
import pandas .algos as _algos
10
10
import pandas .index as _index
11
11
from pandas .lib import Timestamp
12
+ from pandas .core .base import PandasObject
12
13
13
14
from pandas .util .decorators import cache_readonly
14
15
from pandas .core .common import isnull
@@ -47,7 +48,7 @@ def _shouldbe_timestamp(obj):
47
48
or tslib .is_timestamp_array (obj ))
48
49
49
50
50
- class Index (np .ndarray ):
51
+ class Index (PandasObject , np .ndarray ):
51
52
"""
52
53
Immutable ndarray implementing an ordered, sliceable set. The basic object
53
54
storing axis labels for all pandas objects
@@ -142,28 +143,6 @@ def __array_finalize__(self, obj):
142
143
def _shallow_copy (self ):
143
144
return self .view ()
144
145
145
- def __str__ (self ):
146
- """
147
- Return a string representation for a particular Index
148
-
149
- Invoked by str(df) in both py2/py3.
150
- Yields Bytestring in Py2, Unicode String in py3.
151
- """
152
-
153
- if py3compat .PY3 :
154
- return self .__unicode__ ()
155
- return self .__bytes__ ()
156
-
157
- def __bytes__ (self ):
158
- """
159
- Return a string representation for a particular Index
160
-
161
- Invoked by bytes(df) in py3 only.
162
- Yields a bytestring in both py2/py3.
163
- """
164
- encoding = com .get_option ("display.encoding" )
165
- return self .__unicode__ ().encode (encoding , 'replace' )
166
-
167
146
def __unicode__ (self ):
168
147
"""
169
148
Return a string representation for a particular Index
@@ -173,14 +152,6 @@ def __unicode__(self):
173
152
prepr = com .pprint_thing (self , escape_chars = ('\t ' , '\r ' , '\n ' ),quote_strings = True )
174
153
return '%s(%s, dtype=%s)' % (type (self ).__name__ , prepr , self .dtype )
175
154
176
- def __repr__ (self ):
177
- """
178
- Return a string representation for a particular Index
179
-
180
- Yields Bytestring in Py2, Unicode String in py3.
181
- """
182
- return str (self )
183
-
184
155
def to_series (self ):
185
156
"""
186
157
return a series with both index and values equal to the index keys
@@ -1531,28 +1502,6 @@ def _array_values(self):
1531
1502
def dtype (self ):
1532
1503
return np .dtype ('O' )
1533
1504
1534
- def __str__ (self ):
1535
- """
1536
- Return a string representation for a particular Index
1537
-
1538
- Invoked by str(df) in both py2/py3.
1539
- Yields Bytestring in Py2, Unicode String in py3.
1540
- """
1541
-
1542
- if py3compat .PY3 :
1543
- return self .__unicode__ ()
1544
- return self .__bytes__ ()
1545
-
1546
- def __bytes__ (self ):
1547
- """
1548
- Return a string representation for a particular Index
1549
-
1550
- Invoked by bytes(df) in py3 only.
1551
- Yields a bytestring in both py2/py3.
1552
- """
1553
- encoding = com .get_option ("display.encoding" )
1554
- return self .__unicode__ ().encode (encoding , 'replace' )
1555
-
1556
1505
def __unicode__ (self ):
1557
1506
"""
1558
1507
Return a string representation for a particular Index
@@ -1566,14 +1515,6 @@ def __unicode__(self):
1566
1515
1567
1516
return output % summary
1568
1517
1569
- def __repr__ (self ):
1570
- """
1571
- Return a string representation for a particular Index
1572
-
1573
- Yields Bytestring in Py2, Unicode String in py3.
1574
- """
1575
- return str (self )
1576
-
1577
1518
def __len__ (self ):
1578
1519
return len (self .labels [0 ])
1579
1520
0 commit comments