您可以使用
where()NumPy中的函数:
df['New Column'] = np.where(df.columnA.str.match(regex), "this", "that")
您可以使用其他列名称代替标量:
df['New Column'] = np.where(df.columnA.str.match(regex), df.columnB, df.columnC)

您可以使用
where()NumPy中的函数:
df['New Column'] = np.where(df.columnA.str.match(regex), "this", "that")
您可以使用其他列名称代替标量:
df['New Column'] = np.where(df.columnA.str.match(regex), df.columnB, df.columnC)