
您可以使用
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)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)