If you have a large number of CSV files that you want to drop into DataFrame You can define a DataFrame with the variable name "filename_df" by using the following command.
import os import pandas as pd for dirname, _, filenames in os.walk (directory name): for filename in filenames: path = os.path.join(dirname, filename) Dynamically define the file name as a variable name using the #exec command exec("{0}_df = pd.read_csv(path)".format(filename.replace('.csv','')))
Recommended Posts