I have a dataframe which is like below
If i write a code like below
df.iloc[0]
And if i write code like below
df.iloc[3]
I want to concat all the df.iloc[0], df.iloc1, df.iloc2 untill whatever the max rows are are present. But with the help of for loop i'm unable to. Can anyone help me with this?
CodePudding user response:
Use concat
with comprehension:
df1 = pd.concat((df.loc[i] for i in df.index))
Or:
df1 = pd.concat((df.iloc[i] for i in range(len(df.index))))