我想创建一个新列(第三列),我想在其中添加 1 或 0 根据以下条件-:
我很困惑如何处理这个案子。请帮忙。
您可以使用 numpys where 函数,它运行速度很快。
df['matched'] = np.where((df['col1'] == df['col2']), 1, 0)