How can I drop or disable the indices in a pandas Data Frame?
I am learning the pandas from the book \"python for data analysis\" and I already know I can use the datafr
I have a function that may help some. I combine csv files with a header in the following way in python:
def combine_csvs(filedict, combined_file):
files = filedict['files']
df = pd.read_csv(files[0])
for file in files[1:]:
df = pd.concat([df, pd.read_csv(file)])
df.to_csv(combined_file, index=False)
return df
It can take as many files as you need. Call this as:
combine_csvs(dict(files=["file1.csv","file2.csv", "file3.csv"]), 'output.csv')
Or if you are reading the dataframe in python as:
df = combine_csvs(dict(files=["file1.csv","file2.csv"]), 'output.csv')
The combine_csvs fucntion does not save the indices. If you need the indices use 'index=True' instead.