pyspark.pandas.groupby.SeriesGroupBy.unique

SeriesGroupBy. unique ( ) → pyspark.pandas.series.Series [source]

返回组中的唯一值。

Unique 是按未知顺序返回的。它不会进行排序。

示例

>>> df = ps.DataFrame({'a': [1, 1, 1, 2, 2, 2, 3, 3, 3],
...                    'b': [1, 2, 2, 2, 3, 3, 3, 4, 4]}, columns=['a', 'b'])
>>> df.groupby(['a'])['b'].unique().sort_index()  
a
1    [1, 2]
2    [2, 3]
3    [3, 4]
Name: b, dtype: object