I wrote a function which includes a groupby aggregation. For example df.groupby([column, 'columnA', 'columnB', 'columnE'....'columnZ'].sum()
, where column
is the input variable. Since there are many groupby columns, I don't want to rewrite all of them for different aggregation-levels. For one output, I need to have column equal to one string, but for another output, I need to have two column strings (one more layer of aggregation-level).
I am trying to concatenate two strings for example, 'Category_col1'
and 'Category_col2'
.
If I simply add two strings using 'Category_col1' + ', Category_col2'
, it will return 'Category_col1, Category_col2'
My desired output looks like this: 'Category_col1', 'Category_col2'
. An output of "'Category_col1', 'Category_col2'"
would not work if I use that with other groupby aggregation columns. Any way to achieve this?