@@ -2084,72 +2084,31 @@ def mode(self, dropna: bool = True) -> Series:
2084
2084
dtype = self .dtype ,
2085
2085
).__finalize__ (self , method = "mode" )
2086
2086
2087
- def unique (self ) -> ArrayLike :
2087
+ def unique (self , dropna : bool = True ) -> ArrayLike :
2088
2088
"""
2089
2089
Return unique values of Series object.
2090
-
2091
- Uniques are returned in order of appearance. Hash table-based unique,
2092
- therefore does NOT sort.
2093
-
2090
+
2091
+ Parameters
2092
+ ----------
2093
+ dropna : bool, default True
2094
+ If True, exclude NA/null values.
2095
+
2094
2096
Returns
2095
2097
-------
2096
2098
ndarray or ExtensionArray
2097
- The unique values returned as a NumPy array. See Notes.
2098
-
2099
- See Also
2100
- --------
2101
- Series.drop_duplicates : Return Series with duplicate values removed.
2102
- unique : Top-level unique method for any 1-d array-like object.
2103
- Index.unique : Return Index with unique values from an Index object.
2104
-
2105
- Notes
2106
- -----
2107
- Returns the unique values as a NumPy array. In case of an
2108
- extension-array backed Series, a new
2109
- :class:`~api.extensions.ExtensionArray` of that type with just
2110
- the unique values is returned. This includes
2111
-
2112
- * Categorical
2113
- * Period
2114
- * Datetime with Timezone
2115
- * Datetime without Timezone
2116
- * Timedelta
2117
- * Interval
2118
- * Sparse
2119
- * IntegerNA
2120
-
2121
- See Examples section.
2122
-
2099
+ The unique values returned as a NumPy array or ExtensionArray.
2100
+
2123
2101
Examples
2124
2102
--------
2125
- >>> pd.Series([2, 1, 3, 3], name="A").unique()
2126
- array([2, 1, 3])
2127
-
2128
- >>> pd.Series([pd.Timestamp("2016-01-01") for _ in range(3)]).unique()
2129
- <DatetimeArray>
2130
- ['2016-01-01 00:00:00']
2131
- Length: 1, dtype: datetime64[s]
2132
-
2133
- >>> pd.Series(
2134
- ... [pd.Timestamp("2016-01-01", tz="US/Eastern") for _ in range(3)]
2135
- ... ).unique()
2136
- <DatetimeArray>
2137
- ['2016-01-01 00:00:00-05:00']
2138
- Length: 1, dtype: datetime64[s, US/Eastern]
2139
-
2140
- An Categorical will return categories in the order of
2141
- appearance and with the same dtype.
2142
-
2143
- >>> pd.Series(pd.Categorical(list("baabc"))).unique()
2144
- ['b', 'a', 'c']
2145
- Categories (3, object): ['a', 'b', 'c']
2146
- >>> pd.Series(
2147
- ... pd.Categorical(list("baabc"), categories=list("abc"), ordered=True)
2148
- ... ).unique()
2149
- ['b', 'a', 'c']
2150
- Categories (3, object): ['a' < 'b' < 'c']
2103
+ >>> s = pd.Series([1, 2, 2, pd.NA])
2104
+ >>> s.unique()
2105
+ array([1, 2])
2106
+
2107
+ >>> s.unique(dropna=False)
2108
+ array([1, 2, <NA>], dtype=object)
2151
2109
"""
2152
- return super ().unique ()
2110
+ return super ().unique (dropna = dropna )
2111
+
2153
2112
2154
2113
@overload
2155
2114
def drop_duplicates (
0 commit comments