pyspark.pandas.groupby.GroupBy.any

GroupBy.any() → FrameLike[source]

Returns True if any value in the group is truthful, else False.

Examples

>>> df = ps.DataFrame({'A': [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],
...                    'B': [True, True, True, False, False,
...                          False, None, True, None, False]},
...                   columns=['A', 'B'])
>>> df
   A      B
0  1   True
1  1   True
2  2   True
3  2  False
4  3  False
5  3  False
6  4   None
7  4   True
8  5   None
9  5  False
>>> df.groupby('A').any().sort_index()  
       B
A
1   True
2   True
3  False
4   True
5  False