Skip to content

Instantly share code, notes, and snippets.

View henriquepeixoto's full-sized avatar

Henrique Peixoto Machado henriquepeixoto

View GitHub Profile
@abladon
abladon / dfconcat.py
Last active September 16, 2019 22:23
Read multiple files and combine the results into one pandas DataFrame.
import pandas as pd
import glob
# Taken from http://stackoverflow.com/questions/20906474/import-multiple-csv-files-into-pandas-and-concatenate-into-one-dataframe#comment57648172_21232849
# Read multiple files into one dataframe
allfiles = glob.glob('C:/example_folder/*.csv')
df = pd.concat((pd.read_csv(f) for f in allfiles))
# Read multiple files into one dataframe whilst adding custom columns