I have a large dataframe df
for which I have a full list indices
of unique elements in df.index
. I now want to create a list of all the subdataframes indexed by elements in indices
; specifically
list_df = [df.loc[x] for x in indices]
Running this command is taking ages though (df
has about 3e6
rows, and 3e3
unique indices). Is this a reasonable way to perform this operation? I would be very happy to receive any kind of comments or suggestions that could improve the performance of this and related problems.
Thanks in advance!