Replace whole string if it contains substring in pandas

后端 未结 4 2235
感情败类
感情败类 2020-11-27 04:46

I want to replace all strings that contain a specific substring. So for example if I have this dataframe:

import pandas as pd
df = pd.DataFrame({\'name\': [\         


        
4条回答
  •  Happy的楠姐
    2020-11-27 05:07

    A different str.contains

     df['support'][df.name.str.contains('ball')] = 'ball support'
    

提交回复
热议问题