直接上代码,主要使用pd.concat来拼接数据帧 file_dir = "./data_set" # file directory all_csv_list = os . listdir ( file_dir ) # get csv list for single_csv in all_csv_list : single_data_frame = pd . read_csv ( os . path . join
直接上代码,主要使用pd.concat来拼接数据帧
file_dir = "./data_set" # file directoryall_csv_list = os.listdir(file_dir) # get csv list
for single_csv in all_csv_list:
single_data_frame = pd.read_csv(os.path.join(file_dir, single_csv))
# print(single_data_frame.info())
if single_csv == all_csv_list[0]:
all_data_frame = single_data_frame
else: # concatenate all csv to a single dataframe, ingore index
all_data_frame = pd.concat([all_data_frame, single_data_frame], ignore_index=True)