0

I am trying to make several subsets from one Dataframe and then do the repetitive task of manipulating each subset. for example From existing Dataframe, df

for i in range(1, 101):
  globals()['df'+str(i)] = df.iloc[i:10*i, i:20*i]




df1 = df.stack()
df1 = pd.DataFrame(df1, columns=['1'])


df2 = df.stack()
df2 = pd.DataFrame(df2, columns=['2'])

df3 = df.stack()
df3 = pd.DataFrame(df3, columns=['3'])
.
.
.
.
df100 = df.stack()
df100 = pd.DataFrame(df3, columns=['100'])


After df.iloc manipulation, should I write down 100 times same code? Is there any good way to use simple code to create 100ea sub dataframe?

Gihyun Yi
  • 13
  • 3

0 Answers0