def duplicated(self, subset=None, keep='<STR_LIT>'):
from pandas.core.sorting import get_group_index<EOL>from pandas._libs.hashtable import duplicated_int64, _SIZE_HINT_LIMIT<EOL>if self.empty:<EOL><INDENT>return Series(dtype=bool)<EOL><DEDENT>def f(vals):<EOL><INDENT>labels, shape = algorithms.factorize(<EOL>vals, size_hint=min(len(self), _SIZE_HINT_LIMIT))<EOL>return labels.astype('<STR_LIT>', copy=False), len(shape)<EOL><DEDENT>if subset is None:<EOL><INDENT>subset = self.columns<EOL><DEDENT>elif (not np.iterable(subset) or<EOL>isinstance(subset, str) or<EOL>isinstance(subset, tuple) and subset in self.columns):<EOL><INDENT>subset = subset,<EOL><DEDENT>diff = Index(subset).difference(self.columns)<EOL>if not diff.empty:<EOL><INDENT>raise KeyError(diff)<EOL><DEDENT>vals = (col.values for name, col in self.iteritems()<EOL>if name in subset)<EOL>labels, shape = map(list, zip(*map(f, vals)))<EOL>ids = get_group_index(labels, shape, sort=False, xnull=False)<EOL>return Series(duplicated_int64(ids, keep), index=self.index)<EOL>
Return boolean Series denoting duplicate rows, optionally only
considering certain columns.

Parameters
----------
subset : column label or sequence of labels, optional
    Only consider certain columns for identifying duplicates, by
    default use all of the columns
keep : {'first', 'last', False}, default 'first'
    - ``first`` : Mark duplicates as ``True`` except for the
      first occurrence.
    - ``last`` : Mark duplicates as ``True`` except for the
      last occurrence.
    - False : Mark all duplicates as ``True``.

Returns
-------
Series