I am using pandas Python library and I want to add rows to existing DF and also keep the existing one.
My data looks like this:
product price max_move_%
1 100 10
I run loops like this:
for i, row in df_merged.iterrows():
for a in range((row['max_move_%']) * (- 1), row['max_move_%']):
df_merged['price_new'] = df_merged['price'] * (1 - a / 100.00)
I want to get:
product price max_move_% true_move price_new
1 100 10 -10 90
1 100 10 -9 91
.....
1 100 10 10 110
But nothing happens and the df looks the same like before. What can I do to add new values to columns and on the same time leave the data from existing df?
I tried this:
df_loop = []
for i, row in df_merged.iterrows():
for a in range((row['max_move_%']) * (- 1), row['max_move_%'] + 1):
df_loop.append((df_merged['product'], df_merged['price'], f_merged['max_move_%'],a))
pd.DataFrame(df_loop, columns=('product','price','max_move_%','price_new'))
But it doesnt work like I supposed.
Thank you!
price_newcolumn?