pandas: sorting observations within groupby groups
<p>According to the answer to <a href="https://stackoverflow.com/questions/27842613/pandas-groupby-sort-within-groups">pandas groupby sort within groups</a>, in order to sort observations within each group one needs to do a second <code>groupby</code> on the results of the first <code>groupby</code>.  Why a second <code>groupby</code> is needed?  I would've assumed that observations are already arranged into groups after running the first <code>groupby</code> and all that would be needed is a way to enumerate those groups (and run <code>apply</code> with <code>order</code>).</p>