KOTA ITO

Generation

generate functionWed, 07 Dec 2022

データフレーム全体を対象に、文字列を置換する

# 全てのカラムを置換する def replace_all(df, old, new): for col in df.columns: df[col] = df[col].str.replace(old, new) return df replace_all(df, "old", "new")

Questions about programming?Chat with your personal AI assistant