diff --git a/pandas/core/frame.py b/pandas/core/frame.py index c01e551b38c32..8b3a45e7bbc2f 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6721,6 +6721,24 @@ def drop_duplicates( DataFrame or None DataFrame with duplicates removed or None if ``inplace=True``. + Notes + -------- + The methods :meth:`pandas.DataFrame.drop_duplicates` and :meth:`pandas.DataFrame.duplicated` rely on hashing. + Therefore, using a column with mutable objects, such as lists (are not hashable), in the subset parameter may result in unexpected behavior. + + To handle mutable objects, convert the list column to a tuple before using it in the subset. + + >>> df = pd.DataFrame([ + ... {'number': 1, 'item_ids': [1, 2, 3]}, + ... {'number': 1, 'item_ids': [1, 2, 3]}, + ... ]) + + >>> df['item_ids'] = df['item_ids'].apply(tuple) + >>> df.drop_duplicates(inplace=True) + >>> df['item_ids'] = df['item_ids'].apply(list) + number item_ids + 0 1 [1, 2, 3] + See Also -------- DataFrame.value_counts: Count unique combinations of columns. diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 96609fdc1671b..9f1d5387ffdee 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -98,7 +98,7 @@ def hist_series( Returns ------- - matplotlib.AxesSubplot + matplotlib.Axes A histogram plot. See Also @@ -227,7 +227,7 @@ def hist_frame( Returns ------- - matplotlib.AxesSubplot or numpy.ndarray of them + matplotlib.Axes or numpy.ndarray of them See Also -------- @@ -1374,7 +1374,7 @@ def hist( Returns ------- - class:`matplotlib.AxesSubplot` + class:`matplotlib.Axes` Return a histogram plot. See Also @@ -1794,7 +1794,7 @@ def hexbin( Returns ------- - matplotlib.AxesSubplot + matplotlib.Axes The matplotlib ``Axes`` on which the hexbin is plotted. See Also