将列名与行值进行比较并获取其他行值

Compare column name with a row value and getting other row value

我有这样一个数据框:

    request_created_at      sponsor_tier    is_active   status  cash_in  2019/10    ...  2021/07    
0   2019/10 2019/10           2.0           True        1       8901.00             ...                                     
1   2019/10 2019/10           2.0           True        2       7602.00             ... 

我想将我的所有列与日期(例如“2019/10”)与我第一列的值进行比较,并检查状态是否 == 1 以及状态是否 == 1 我想将我的现金价值复制到列“2019/10”行

def check_status (row, data):
    if (row.status == 1) & (row.request_created_at == data):
        return row.total_cash_in
    elif (row.status == 4) & (row.request_created_at == data):
        return row.total_cash_in
    elif (row.status == 7) & (row.request_created_at == data):
        return row.total_cash_in
    else:
        return 0

然后

for data in array_datas:
    df[data] = df.apply(lambda row: check_status(row,data), axis=1)