This code only shows multiplied the price of products and not the product name. Also it displays"unnamed" in the final output.how to solve this?
newdf=df[['Product_name','Product_price']]
newdf=df.Product_price*2
newdf.to_csv('newsales.csv')
newdf
CodePudding user response:
In the second line, you need specify the column by doing that:
newdf['Product_name'] = df.Product_price * 2
or
newdf['Product_name'] = newdf['Product_name'] * 2
CodePudding user response:
newdf=df[['Product_name','Product_price']]
newdf['Product_price'] = newdf['Product_price']*2
newdf.to_csv('newsales.csv', index=False)
newdf
Does it.