df2 = df[df['A'] > 2] df2['B'] = value
您不想使用Jeffs解决方案,因为您的条件计算 df2 是长还是其他原因,则可以使用以下命令:
df2
df.loc[df2.index.tolist(), 'B'] = value
df2.index.tolist()