How to combine multiple CSV files into one DataFrame
If your all .csv files in the same directory, you can use the following methods:
df = pd.concat(map(pd.read_csv, all_files))
Full Source:
import pandas as pd
import numpy as np
import glob
import os
path = r'D:\csv'
all_files = glob.glob(path + "/*.csv")
df = pd.concat(map(pd.read_csv, all_files))
Method 2: Reading Multiple CSVs Into Pandas

import pandas as pd
import numpy as np
import glob
path = r'D:\csv'
all_files = glob.glob(path + "/*.csv")
df_files = (pd.read_csv(f) for f in all_files)
df = pd.concat(df_files, ignore_index=True)
Glob: The python module glob provides Unix style pathname pattern expansion. So, using glob.glob('*.csv') will give you all the .csv files in a folder as a list.
Related Topics
- Pandas DataFrame: GroupBy Examples
- Pandas DataFrame Aggregation and Grouping
- How to Sort Pandas DataFrame
- Pandas DataFrame: query() function
- Finding and removing duplicate rows in Pandas DataFrame
- How to Replace NaN Values With Zeros in Pandas DataFrame
- How to read CSV File using Pandas DataFrame.read_csv()
- How to Convert Pandas DataFrame to NumPy Array
- How to shuffle a DataFrame rows
- Create new column in DataFrame based on the existing columns
- New Pandas dataframe column based on if-else condition
- How to Convert a Dictionary to Pandas DataFrame
- Rename Pandas columns/index names (labels)