@@ -1164,6 +1164,9 @@ def to_frame(self, index=True, name=None):
11641164
11651165 @property
11661166 def name (self ):
1167+ """
1168+ Return Index or MultiIndex name.
1169+ """
11671170 return self ._name
11681171
11691172 @name .setter
@@ -1645,21 +1648,230 @@ def is_unique(self) -> bool:
16451648
16461649 @property
16471650 def has_duplicates (self ) -> bool :
1651+ """
1652+ Check if the Index has duplicate values.
1653+
1654+ Returns
1655+ -------
1656+ bool
1657+ Whether or not the Index has duplicate values.
1658+
1659+ Examples
1660+ --------
1661+ >>> idx = pd.Index([1, 5, 7, 7])
1662+ >>> idx.has_duplicates
1663+ True
1664+
1665+ >>> idx = pd.Index([1, 5, 7])
1666+ >>> idx.has_duplicates
1667+ False
1668+
1669+ >>> idx = pd.Index(["Watermelon", "Orange", "Apple",
1670+ ... "Watermelon"]).astype("category")
1671+ >>> idx.has_duplicates
1672+ True
1673+
1674+ >>> idx = pd.Index(["Orange", "Apple",
1675+ ... "Watermelon"]).astype("category")
1676+ >>> idx.has_duplicates
1677+ False
1678+ """
16481679 return not self .is_unique
16491680
16501681 def is_boolean (self ) -> bool :
1682+ """
1683+ Check if the Index only consists of booleans.
1684+
1685+ Returns
1686+ -------
1687+ bool
1688+ Whether or not the Index only consists of booleans.
1689+
1690+ See Also
1691+ --------
1692+ is_integer : Check if the Index only consists of integers.
1693+ is_floating : Check if the Index is a floating type.
1694+ is_numeric : Check if the Index only consists of numeric data.
1695+ is_object : Check if the Index is of the object dtype.
1696+ is_categorical : Check if the Index holds categorical data.
1697+ is_interval : Check if the Index holds Interval objects.
1698+ is_mixed : Check if the Index holds data with mixed data types.
1699+
1700+ Examples
1701+ --------
1702+ >>> idx = pd.Index([True, False, True])
1703+ >>> idx.is_boolean()
1704+ True
1705+
1706+ >>> idx = pd.Index(["True", "False", "True"])
1707+ >>> idx.is_boolean()
1708+ False
1709+
1710+ >>> idx = pd.Index([True, False, "True"])
1711+ >>> idx.is_boolean()
1712+ False
1713+ """
16511714 return self .inferred_type in ["boolean" ]
16521715
16531716 def is_integer (self ) -> bool :
1717+ """
1718+ Check if the Index only consists of integers.
1719+
1720+ Returns
1721+ -------
1722+ bool
1723+ Whether or not the Index only consists of integers.
1724+
1725+ See Also
1726+ --------
1727+ is_boolean : Check if the Index only consists of booleans.
1728+ is_floating : Check if the Index is a floating type.
1729+ is_numeric : Check if the Index only consists of numeric data.
1730+ is_object : Check if the Index is of the object dtype.
1731+ is_categorical : Check if the Index holds categorical data.
1732+ is_interval : Check if the Index holds Interval objects.
1733+ is_mixed : Check if the Index holds data with mixed data types.
1734+
1735+ Examples
1736+ --------
1737+ >>> idx = pd.Index([1, 2, 3, 4])
1738+ >>> idx.is_integer()
1739+ True
1740+
1741+ >>> idx = pd.Index([1.0, 2.0, 3.0, 4.0])
1742+ >>> idx.is_integer()
1743+ False
1744+
1745+ >>> idx = pd.Index(["Apple", "Mango", "Watermelon"])
1746+ >>> idx.is_integer()
1747+ False
1748+ """
16541749 return self .inferred_type in ["integer" ]
16551750
16561751 def is_floating (self ) -> bool :
1752+ """
1753+ Check if the Index is a floating type.
1754+
1755+ The Index may consist of only floats, NaNs, or a mix of floats,
1756+ integers, or NaNs.
1757+
1758+ Returns
1759+ -------
1760+ bool
1761+ Whether or not the Index only consists of only consists of floats, NaNs, or
1762+ a mix of floats, integers, or NaNs.
1763+
1764+ See Also
1765+ --------
1766+ is_boolean : Check if the Index only consists of booleans.
1767+ is_integer : Check if the Index only consists of integers.
1768+ is_numeric : Check if the Index only consists of numeric data.
1769+ is_object : Check if the Index is of the object dtype.
1770+ is_categorical : Check if the Index holds categorical data.
1771+ is_interval : Check if the Index holds Interval objects.
1772+ is_mixed : Check if the Index holds data with mixed data types.
1773+
1774+ Examples
1775+ --------
1776+ >>> idx = pd.Index([1.0, 2.0, 3.0, 4.0])
1777+ >>> idx.is_floating()
1778+ True
1779+
1780+ >>> idx = pd.Index([1.0, 2.0, np.nan, 4.0])
1781+ >>> idx.is_floating()
1782+ True
1783+
1784+ >>> idx = pd.Index([1, 2, 3, 4, np.nan])
1785+ >>> idx.is_floating()
1786+ True
1787+
1788+ >>> idx = pd.Index([1, 2, 3, 4])
1789+ >>> idx.is_floating()
1790+ False
1791+ """
16571792 return self .inferred_type in ["floating" , "mixed-integer-float" , "integer-na" ]
16581793
16591794 def is_numeric (self ) -> bool :
1795+ """
1796+ Check if the Index only consists of numeric data.
1797+
1798+ Returns
1799+ -------
1800+ bool
1801+ Whether or not the Index only consists of numeric data.
1802+
1803+ See Also
1804+ --------
1805+ is_boolean : Check if the Index only consists of booleans.
1806+ is_integer : Check if the Index only consists of integers.
1807+ is_floating : Check if the Index is a floating type.
1808+ is_object : Check if the Index is of the object dtype.
1809+ is_categorical : Check if the Index holds categorical data.
1810+ is_interval : Check if the Index holds Interval objects.
1811+ is_mixed : Check if the Index holds data with mixed data types.
1812+
1813+ Examples
1814+ --------
1815+ >>> idx = pd.Index([1.0, 2.0, 3.0, 4.0])
1816+ >>> idx.is_numeric()
1817+ True
1818+
1819+ >>> idx = pd.Index([1, 2, 3, 4.0])
1820+ >>> idx.is_numeric()
1821+ True
1822+
1823+ >>> idx = pd.Index([1, 2, 3, 4])
1824+ >>> idx.is_numeric()
1825+ True
1826+
1827+ >>> idx = pd.Index([1, 2, 3, 4.0, np.nan])
1828+ >>> idx.is_numeric()
1829+ True
1830+
1831+ >>> idx = pd.Index([1, 2, 3, 4.0, np.nan, "Apple"])
1832+ >>> idx.is_numeric()
1833+ False
1834+ """
16601835 return self .inferred_type in ["integer" , "floating" ]
16611836
16621837 def is_object (self ) -> bool :
1838+ """
1839+ Check if the Index is of the object dtype.
1840+
1841+ Returns
1842+ -------
1843+ bool
1844+ Whether or not the Index is of the object dtype.
1845+
1846+ See Also
1847+ --------
1848+ is_boolean : Check if the Index only consists of booleans.
1849+ is_integer : Check if the Index only consists of integers.
1850+ is_floating : Check if the Index is a floating type.
1851+ is_numeric : Check if the Index only consists of numeric data.
1852+ is_categorical : Check if the Index holds categorical data.
1853+ is_interval : Check if the Index holds Interval objects.
1854+ is_mixed : Check if the Index holds data with mixed data types.
1855+
1856+ Examples
1857+ --------
1858+ >>> idx = pd.Index(["Apple", "Mango", "Watermelon"])
1859+ >>> idx.is_object()
1860+ True
1861+
1862+ >>> idx = pd.Index(["Apple", "Mango", 2.0])
1863+ >>> idx.is_object()
1864+ True
1865+
1866+ >>> idx = pd.Index(["Watermelon", "Orange", "Apple",
1867+ ... "Watermelon"]).astype("category")
1868+ >>> idx.object()
1869+ False
1870+
1871+ >>> idx = pd.Index([1.0, 2.0, 3.0, 4.0])
1872+ >>> idx.is_object()
1873+ False
1874+ """
16631875 return is_object_dtype (self .dtype )
16641876
16651877 def is_categorical (self ) -> bool :
@@ -1668,12 +1880,19 @@ def is_categorical(self) -> bool:
16681880
16691881 Returns
16701882 -------
1671- boolean
1883+ bool
16721884 True if the Index is categorical.
16731885
16741886 See Also
16751887 --------
16761888 CategoricalIndex : Index for categorical data.
1889+ is_boolean : Check if the Index only consists of booleans.
1890+ is_integer : Check if the Index only consists of integers.
1891+ is_floating : Check if the Index is a floating type.
1892+ is_numeric : Check if the Index only consists of numeric data.
1893+ is_object : Check if the Index is of the object dtype.
1894+ is_interval : Check if the Index holds Interval objects.
1895+ is_mixed : Check if the Index holds data with mixed data types.
16771896
16781897 Examples
16791898 --------
@@ -1699,9 +1918,67 @@ def is_categorical(self) -> bool:
16991918 return self .inferred_type in ["categorical" ]
17001919
17011920 def is_interval (self ) -> bool :
1921+ """
1922+ Check if the Index holds Interval objects.
1923+
1924+ Returns
1925+ -------
1926+ bool
1927+ Whether or not the Index holds Interval objects.
1928+
1929+ See Also
1930+ --------
1931+ IntervalIndex : Index for Interval objects.
1932+ is_boolean : Check if the Index only consists of booleans.
1933+ is_integer : Check if the Index only consists of integers.
1934+ is_floating : Check if the Index is a floating type.
1935+ is_numeric : Check if the Index only consists of numeric data.
1936+ is_object : Check if the Index is of the object dtype.
1937+ is_categorical : Check if the Index holds categorical data.
1938+ is_mixed : Check if the Index holds data with mixed data types.
1939+
1940+ Examples
1941+ --------
1942+ >>> idx = pd.Index([pd.Interval(left=0, right=5),
1943+ ... pd.Interval(left=5, right=10)])
1944+ >>> idx.is_interval()
1945+ True
1946+
1947+ >>> idx = pd.Index([1, 3, 5, 7])
1948+ >>> idx.is_interval()
1949+ False
1950+ """
17021951 return self .inferred_type in ["interval" ]
17031952
17041953 def is_mixed (self ) -> bool :
1954+ """
1955+ Check if the Index holds data with mixed data types.
1956+
1957+ Returns
1958+ -------
1959+ bool
1960+ Whether or not the Index holds data with mixed data types.
1961+
1962+ See Also
1963+ --------
1964+ is_boolean : Check if the Index only consists of booleans.
1965+ is_integer : Check if the Index only consists of integers.
1966+ is_floating : Check if the Index is a floating type.
1967+ is_numeric : Check if the Index only consists of numeric data.
1968+ is_object : Check if the Index is of the object dtype.
1969+ is_categorical : Check if the Index holds categorical data.
1970+ is_interval : Check if the Index holds Interval objects.
1971+
1972+ Examples
1973+ --------
1974+ >>> idx = pd.Index(['a', np.nan, 'b'])
1975+ >>> idx.is_mixed()
1976+ True
1977+
1978+ >>> idx = pd.Index([1.0, 2.0, 3.0, 5.0])
1979+ >>> idx.is_mixed()
1980+ False
1981+ """
17051982 return self .inferred_type in ["mixed" ]
17061983
17071984 def holds_integer (self ):
@@ -1719,6 +1996,9 @@ def inferred_type(self):
17191996
17201997 @cache_readonly
17211998 def is_all_dates (self ) -> bool :
1999+ """
2000+ Whether or not the index values only consist of dates.
2001+ """
17222002 return is_datetime_array (ensure_object (self .values ))
17232003
17242004 # --------------------------------------------------------------------
0 commit comments