I am trying to append data frames together when I "find" them in a for loop, as well as add additional columns.
By this I mean:
I have an existing data frame X
a b c
1 2 3
5 6 7
9 10 11
I have a for loop which I "find" certain rows which meet conditional arguments. I then want to add these rows to an empty frame, with additional columns.so new data frame Y would be:
a b c next
5 6 7 8
where next is the new column added. So far I have tried to add in the following way:
allInfo = pd.DataFrame(columns=[list(X), "next"])
allInfo = allInfo.append([a[a.apply(lambda x:someConditional,axis=1)], valueNext],ignore_index=True)
But this does not work. Is there a simple way to do this?
Thanks!