目前正在尝试执行以下操作:
import pandas as pd
import numpy as np
使用列索引创建空数据框
currentDataToAdd = pd.read_csv('product-export-empty.csv', header=0)
导入需要重新格式化的数据
newData = pd.read_csv('ChermsideStock.csv', header=0)
将数据重新格式化为currentDataToAdd(所有标签都存在于两个数据框中)
currentDataToAdd.loc[:,'sku'] = newData3.loc[:,'Barcode']
currentDataToAdd.loc[:,'name'] = newData3.loc[:,'Description']
currentDataToAdd.loc[:,'tax_name'] = newData3.loc[:,'Sales_Tax']
currentDataToAdd.loc[:,'supply_price'] = newData3.loc[:,'Cost']
currentDataToAdd.loc[:,'retail_price'] = newData3.loc[:,'Sell']
问题是我在currentDataToAdd中得到的是数据,但是列错了。请帮忙。我做错了什么?
newData3 enter image description here
currentDataToAdd enter image description here
结果