def mode(values, dropna=True):
from pandas import Series<EOL>values = _ensure_arraylike(values)<EOL>original = values<EOL>if is_categorical_dtype(values):<EOL><INDENT>if isinstance(values, Series):<EOL><INDENT>return Series(values.values.mode(dropna=dropna), name=values.name)<EOL><DEDENT>return values.mode(dropna=dropna)<EOL><DEDENT>if dropna and is_datetimelike(values):<EOL><INDENT>mask = values.isnull()<EOL>values = values[~mask]<EOL><DEDENT>values, dtype, ndtype = _ensure_data(values)<EOL>f = getattr(htable, "<STR_LIT>".format(dtype=ndtype))<EOL>result = f(values, dropna=dropna)<EOL>try:<EOL><INDENT>result = np.sort(result)<EOL><DEDENT>except TypeError as e:<EOL><INDENT>warn("<STR_LIT>".format(error=e))<EOL><DEDENT>result = _reconstruct_data(result, original.dtype, original)<EOL>return Series(result)<EOL>
Returns the mode(s) of an array.

Parameters
----------
values : array-like
    Array over which to check for duplicate values.
dropna : boolean, default True
    Don't consider counts of NaN/NaT.

    .. versionadded:: 0.24.0

Returns
-------
mode : Series