Admittedly, my use my seem odd. I have used groupby.agg to combine results from multiple experiments, as we discussed a couple of weeks ago. But now I have a new problem. I have data where elements are not scalar but vectors. So I have a dataframe where some columns are a vector (using a list or a tuple).
File "./plot_stuff2.py", line 231, in combined_cols
rdf = df.groupby(list(columns_to_group)).agg(d).reset_index()
File "/home/nbecker/.local/lib/python2.7/site-packages/pandas/core/groupby.py", line 344, in agg
return self.aggregate(func, *args, **kwargs)
File "/home/nbecker/.local/lib/python2.7/site-packages/pandas/core/groupby.py", line 1727, in aggregate
result[col] = colg.aggregate(agg_how)
File "/home/nbecker/.local/lib/python2.7/site-packages/pandas/core/groupby.py", line 1420, in aggregate
return self._python_agg_general(func_or_funcs, *args, **kwargs)
File "/home/nbecker/.local/lib/python2.7/site-packages/pandas/core/groupby.py", line 476, in _python_agg_general
result, counts = self.grouper.agg_series(obj, f)
File "/home/nbecker/.local/lib/python2.7/site-packages/pandas/core/groupby.py", line 883, in agg_series
return self._aggregate_series_pure_python(obj, func)
File "/home/nbecker/.local/lib/python2.7/site-packages/pandas/core/groupby.py", line 917, in _aggregate_series_pure_python
raise ValueError('Function does not reduce')
ValueError: Function does not reduce
I wonder if this restriction is unnecessary? Or maybe I just shouldn't be trying to use groupby.agg for this. Or perhaps I should be using some other approach entirely.
The purpose of this is to combine results from experiments. The combinations would be simple functions like sum. In this case, it would be sum element-by-element of these vectors, producing a vector result to be put into the new df.