2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have 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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?