| [ Web Proxy ] |
| Viewing: https://dataframes.bigquery.dev/reference/api/bigframes.pandas.Series.drop_duplicates.html | [Back] [Original] |
Section Navigation
Return Series with duplicate values removed.
Examples:
Generate a Series with duplicated entries.
>>> import bigframes.pandas as bpd
>>> s = bpd.Series(['llama', 'cow', 'llama', 'beetle', 'llama', 'hippo'],
... name='animal')
>>> s
0 llama
1 cow
2 llama
3 beetle
4 llama
5 hippo
Name: animal, dtype: string
With the keep parameter, the selection behaviour of duplicated values can be changed. The value first keeps the first occurrence for each set of duplicated entries. The default value of keep is first.
>>> s.drop_duplicates()
0 llama
1 cow
3 beetle
5 hippo
Name: animal, dtype: string
The value last for parameter keep keeps the last occurrence for each set of duplicated entries.
>>> s.drop_duplicates(keep='last')
1 cow
3 beetle
4 llama
5 hippo
Name: animal, dtype: string
The value False for parameter keep discards all sets of duplicated entries.
>>> s.drop_duplicates(keep=False)
1 cow
3 beetle
5 hippo
Name: animal, dtype: string
keep ({first, last, False}, default first)
Method to handle dropping duplicates:
first : Drop duplicates except for the first occurrence.
last : Drop duplicates except for the last occurrence.
False : Drop all duplicates.
Series with duplicates dropped or None if inplace=True.
Copyright 2019, Google.
Created using Sphinx 8.1.3.
Built with the PyData Sphinx Theme 0.19.0.
| Web Proxy Viewer | New URL | Original Page |