Closed
Description
This should exit the interpreter.
In [1]: import pandas as pd
In [2]: df = pd.DataFrame({"A": pd.Categorical(['a', 'a'], categories=['a', 'b']),
...: "B": [1, 1]})
...:
In [3]: import sys
In [4]: def f(x):
...: if len(x) == 0:
...: sys.exit(1)
...: return len(x)
...:
In [5]: df.groupby('A').agg(f)
Out[5]:
B
A
a 2.0
b NaN
Instead, I think groupby assumes the output of the custom aggfunc is NaN
.