LoginSignup
2
4

More than 1 year has passed since last update.

pandasで複数CSVファイルを読み込んで、結合する

Last updated at Posted at 2021-10-05
python
import os
import pandas as pd

#ゲットファイルリスト
path = 'testData/'
files = os.listdir(path)
train_csv = list(filter(lambda x:(x[0:6] == 'train_' and x[-4:] == '.csv'),files))

#ゲットCSVデータ
data_list = []
for fileitem in train_csv:
    tmp = pd.read_csv(path + fileitem,header=0)
    data_list.append(tmp)

#結合
dataset = pd.concat(data_list,ignore_index = False)
2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4