Reputation: 10423
I've several data frames which all have the same columns:
df_list = [df1,df2,df3,dfn]
And I want to append those to a new data frame if a given condition is satisfied.
for df in df_list:
if some_condition:
new_df.append(df)
But that didn;t work, so I try this:
new_df = pd.DataFrame()
for column in df1.columns:
new_df[column] = []
And just for testing it:
new_df.append(df1)
but new_df
it's still empty.
It only works if I assign it explicity
new_df = new_df.append(df1)
Upvotes: 1
Views: 103