[ Web Proxy ]
URL:
Viewing: https://dataframes.bigquery.dev/reference/api/bigframes.pandas.Series.drop_duplicates.html [Back]  [Original]

bigframes.pandas.Series.drop_duplicates — bigframes documentation
Back to top
Search the docs ...:

bigframes.pandas.Series.drop_duplicates#

Series.drop_duplicates(*, keep: str = 'first') Series[source]#

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
Parameters:

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.

Returns:

Series with duplicates dropped or None if inplace=True.

Return type:

bigframes.pandas.Series


Web Proxy Viewer  |  New URL  |  Original Page