I have a large, two column dataframe. I use groupby
to cut the dataframe up into groups of 7 entries each. However, I now wish to order each of the subgroups of 7 rows by the value in the 2nd column. How would I go about doing that?
I use
from numpy import arange
from pandas import DataFrame
df = DataFrame(etc.)
<Process the dataframe into a usable form>
groups = df.groupby(arange(len(df.index))//7)
to split the dataframe and then I can iterate over it and print each entry with
for frame in groups:
print(frame)
However, when it comes to manipulating the groups, sorting them and copying them into a new dataframe for final usage, I am a little stumped on how to proceed.