I have a data frame like so:
df = pd.DataFrame({
'A':np.random.random(20),
'B':np.random.random(20),
'Gen': [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]
})
Is there a simple way with pandas to find the range (min and max values) in each column by group 'Gen'? In real life, I can have lots of columns A, B, ... (>20). The result could look something like:
Var Gen Min Max
A 1 x x
B 1 x x
A 2 x x
...