Import multiple csv files into pandas and concatenate into one DataFrame

I would like to read several csv files from a directory into pandas and concatenate them into one big DataFrame. I have not been able to figure it out though. Here is what I have so far:

    import glob
    import pandas as pd

    # get data file names
    path =r'C:\DRO\DCL_rawdata_files'
    filenames = glob.glob(path + "/*.csv")

    dfs = []
    for filename in filenames:

    # Concatenate all data into one DataFrame
    big_frame = pd.concat(dfs, ignore_index=True)

I guess I need some help within the for loop???

If you have same columns in all your csv files then you can try the code below. I have added header=0 so that after reading csv first row can be assigned as the column names.

    path =r'C:\DRO\DCL_rawdata_files' # use your path
    allFiles = glob.glob(path + "/*.csv")

    list_ = []

    for file_ in allFiles:
        df = pd.read_csv(file_,index_col=None, header=0)

    frame = pd.concat(list_, axis = 0, ignore_index = True)


Back to homepage or read more recommendations: