Reputation: 57
Hey guys really confused as to how to approach this, tried looking all over the place. I want to save the selected columns in a new excel file. Any help is appreciated!
import pandas as pd
import numpy as np
data = pd.read_excel('C:\\Users\\me\\Downloads\\Reconcile.xlsx')
data[['batched_at', 'batch_id', 'total', 'customer_firstname', 'customer_lastname']]
data.to_excel('C:\\Users\\me\\Downloads\\Newfile.xlsx')
Upvotes: 0
Views: 59
Reputation: 186
The third line does nothing here, assign it to a new dataframe and save that one.
import pandas as pd
import numpy as np
data = pd.read_excel('C:\\Users\\me\\Downloads\\Reconcile.xlsx')
new_data = data[['batched_at', 'batch_id', 'total', 'customer_firstname', 'customer_lastname']]
new_data.to_excel('C:\\Users\\me\\Downloads\\Newfile.xlsx')
Upvotes: 1