How to I sperate rows and form a new dataframe with the series ?
Suppose I have a dataframe df and I am iterating over df with the following and trying to append over an empty dataframe
df = pd.DataFrame(np.random.randint(low=0, high=10, size=(5, 5)),
columns=['a', 'b', 'c', 'd', 'e'])
df1 = pd.DataFrame()
df2 = pd.DataFrame()
for index,row in df.iterrows():
if (few conditions goes here):
df1.append(row)
else:
df2.append(row)
the type of each rows over iteration is a series, but if I append it to empty dataframe it appends rows as columns and columns as row. Is there a fix for this ?