|
32 | 32 | from pandas.compat.numpy import function as nv |
33 | 33 | from pandas.errors import PerformanceWarning |
34 | 34 | from pandas.util._decorators import ( |
35 | | - doc, |
36 | 35 | set_module, |
37 | 36 | ) |
38 | 37 | from pandas.util._exceptions import find_stack_level |
@@ -885,10 +884,38 @@ def _first_fill_value_loc(self): |
885 | 884 | diff = np.r_[np.diff(indices), 2] |
886 | 885 | return indices[(diff > 1).argmax()] + 1 |
887 | 886 |
|
888 | | - @doc(ExtensionArray.duplicated) |
889 | 887 | def duplicated( |
890 | 888 | self, keep: Literal["first", "last", False] = "first" |
891 | 889 | ) -> npt.NDArray[np.bool_]: |
| 890 | + """ |
| 891 | + Return boolean ndarray denoting duplicate values. |
| 892 | +
|
| 893 | + Parameters |
| 894 | + ---------- |
| 895 | + keep : {'first', 'last', False}, default 'first' |
| 896 | + - ``first`` : Mark duplicates as ``True`` except for the first occurrence. |
| 897 | + - ``last`` : Mark duplicates as ``True`` except for the last occurrence. |
| 898 | + - False : Mark all duplicates as ``True``. |
| 899 | +
|
| 900 | + Returns |
| 901 | + ------- |
| 902 | + ndarray[bool] |
| 903 | + With true in indices where elements are duplicated and false otherwise. |
| 904 | +
|
| 905 | + See Also |
| 906 | + -------- |
| 907 | + DataFrame.duplicated : Return boolean Series denoting |
| 908 | + duplicate rows. |
| 909 | + Series.duplicated : Indicate duplicate Series values. |
| 910 | + api.extensions.ExtensionArray.unique : Compute the ExtensionArray |
| 911 | + of unique values. |
| 912 | +
|
| 913 | + Examples |
| 914 | + -------- |
| 915 | + >>> pd.array([1, 1, 2, 3, 3], dtype=pd.SparseDtype(np.int64)).duplicated() |
| 916 | + array([False, True, False, False, True]) |
| 917 | + """ |
| 918 | + |
892 | 919 | values = np.asarray(self) |
893 | 920 | mask = np.asarray(self.isna()) |
894 | 921 | return algos.duplicated(values, keep=keep, mask=mask) |
|
0 commit comments