I am trying to combine multiple CSVs in a folder then delete the first 3 columns. My code combines the files ok but I can't drop the columns. Can anyone see the issue?
import pandas as pd
import glob
path = r'C:\Users\****' # use your path
all_files = glob.glob(path + "/*.csv")
li = []
for filename in all_files:
df = pd.read_csv(filename, index_col=None, header=0)
li.append(df)
frame = pd.concat(li, axis=0, ignore_index=True)
frame.drop(frame.columns[[0, 1, 2]], axis=1)
print(frame)
frame.to_csv('out.csv', index=False)
usecols, with usepd.read_csv('foo.csv', usecols=[3:])?frame = frame.drop(frame.columns[[0, 1, 2]], axis=1)is one way.