@@ -944,6 +944,14 @@ def __array_wrap__(self, result, context=None):
944
944
def dtype (self ) -> DtypeObj :
945
945
"""
946
946
Return the dtype object of the underlying data.
947
+
948
+ Examples
949
+ --------
950
+ >>> idx = pd.Index([1, 2, 3])
951
+ >>> idx
952
+ Index([1, 2, 3], dtype='int64')
953
+ >>> idx.dtype
954
+ dtype('int64')
947
955
"""
948
956
return self ._data .dtype
949
957
@@ -1599,6 +1607,14 @@ def to_frame(
1599
1607
def name (self ) -> Hashable :
1600
1608
"""
1601
1609
Return Index or MultiIndex name.
1610
+
1611
+ Examples
1612
+ --------
1613
+ >>> idx = pd.Index([1, 2, 3], name='x')
1614
+ >>> idx
1615
+ Index([1, 2, 3], dtype='int64', name='x')
1616
+ >>> idx.name
1617
+ 'x'
1602
1618
"""
1603
1619
return self ._name
1604
1620
@@ -2658,6 +2674,14 @@ def holds_integer(self) -> bool:
2658
2674
def inferred_type (self ) -> str_t :
2659
2675
"""
2660
2676
Return a string of the type inferred from the values.
2677
+
2678
+ Examples
2679
+ --------
2680
+ >>> idx = pd.Index([1, 2, 3])
2681
+ >>> idx
2682
+ Index([1, 2, 3], dtype='int64')
2683
+ >>> idx.inferred_type
2684
+ 'integer'
2661
2685
"""
2662
2686
return lib .infer_dtype (self ._values , skipna = False )
2663
2687
@@ -4957,6 +4981,14 @@ def values(self) -> ArrayLike:
4957
4981
--------
4958
4982
Index.array : Reference to the underlying data.
4959
4983
Index.to_numpy : A NumPy array representing the underlying data.
4984
+
4985
+ Examples
4986
+ --------
4987
+ >>> idx = pd.Index([1, 2, 3])
4988
+ >>> idx
4989
+ Index([1, 2, 3], dtype='int64')
4990
+ >>> idx.values
4991
+ array([1, 2, 3])
4960
4992
"""
4961
4993
return self ._data
4962
4994
@@ -7177,6 +7209,14 @@ def max(self, axis=None, skipna: bool = True, *args, **kwargs):
7177
7209
def shape (self ) -> Shape :
7178
7210
"""
7179
7211
Return a tuple of the shape of the underlying data.
7212
+
7213
+ Examples
7214
+ --------
7215
+ >>> idx = pd.Index([1, 2, 3])
7216
+ >>> idx
7217
+ Index([1, 2, 3], dtype='int64')
7218
+ >>> idx.shape
7219
+ (3,)
7180
7220
"""
7181
7221
# See GH#27775, GH#27384 for history/reasoning in how this is defined.
7182
7222
return (len (self ),)
0 commit comments