У меня большой индекс csv с числом столбцов x и числом строк y. Я хочу, чтобы мой код проходил через каждый CSV (пока цикл индекса) и объединить столбцы с конкретными заголовками в новый столбец, а затем сохранить CSV в новый путь. Это мой код, но я получаю ошибку:
'utf-8' codec can't decode byte 0xa9 in position 33: invalid start byte
Есть идеи?
import os
import pandas as pd
#code to add new row to all csvs with unique identifier stamp that combines
the following:
#wellkey+drillkey+lat+long+spuddate
files=['Apr 23 2018.csv','Apr 20 2018.csv']
index=0
os.chdir('file path')
#code to loop through all the files listed above
while index < len(files):
os.chdir('file path')
current_file=files[index]
#unique identifier column
df=pd.read_csv(current_file)
df['Unique Identifier']=df['A'] + "-" + df['B'] + "-" + df['C'] + "-" +
df['D'] + "-" + df['E']
df.to_csv(current_file)
#save new csv
os.chdir('New file Path')
index = index + 1
Спасибо за ваши советы / комментарии / исправления.