特定の条件に合う場合に代入
title
にほげ
がある行のtype
に2を代入します
df.loc[df['title'].str.contains('ほげ'), 'type'] = 2
NaNを抽出
typeがNaNのものを抽出
df[df['type'].isna()]
複数CSVをpandasに読み込む
import pandas as pd
import glob
all_files = glob.glob("./csv/*.csv")
li = []
for filename in all_files:
df = pd.read_csv(filename)
li.append(df)
df = pd.concat(li, axis=0, ignore_index=True)