I have excel(test.xlsx) sheet having multiple columns,col1,col2,col3,col4 and so on.. I want to perform some operation on col2,col3 and then the output output.xlsx having all the columns again with the updated col2,col3..
What I was trying..
df = pd.read_xlsx('test.xlsx')
col = ['col2','col3']
df_with_some_operation = df[col].<some_op>
df_with_some_operation.to_excel(output.xlsx)
Need help on this code so that all the columns including col2,col3 get included in final output.xlsx
For better visualisation ... Check below, I do not want to change the column names, only want to update the content.. I picked this example to made it simplify .. col2 and col3 - > multiplied by 2 . just a note, there are multiple columns in actual, but only on 2 I have to do some work..
input.xlsx
col1 col2 col3
1 2 3
output.xls
col1 col2 col3
1 4 6
drop?to_excel<and then the logic work>. Vectorised operations may be possible instead of the more generic but inefficientpd.DataFrame.apply.