I want to do a conditional aggregation with pandas but with two conditionals, I have seen this Python Pandas Conditional Sum with Groupby and I have found really useful but if I added another condition for example:
g.apply(lambda x: x[x[x['key2'] == 'one']['data2']<0.4]['data1'].sum())
i.e add a condition that I want to sum the ones which Key2 is equal to one and that data2 is less than 0.4. But this doesnt work.
This is the error that I got: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match