How to get the column names of a DataFrame GroupBy object?
<p>How can I get the column names of a GroupBy object? The object does not supply a columns propertiy. I can aggregate the object first or extract a DataFrame with the get_group()-method but this is either a power consuming hack or error prone if there are dismissed columns (strings for example).</p>

<p>Looking at the source code of <code>__getitem__</code>, it seems that you can get the column names with</p>

<pre><code>g.obj.columns
</code></pre>

<p>where g is the groupby object. Apparently <code>g.obj</code> links to the DataFrame.</p>

python pandas