我有一個(gè)像這樣的數(shù)據(jù)框:Source | Description |Incomes | Tax 12 |Incomes | Payment |Incomes | Check 152 |Incomes | Incoming 21 |Incomes | Receiving |Payments | Tax |Payments | Incoming 7 |Payments | Receiving 12 |Payments | Check |Payments | Incoming |首先,我替換所有包含IncomingorCheck和using的內(nèi)容:IncomesCheckdf.locSource | Description |Incomes | Incomes |Incomes | Payment |Incomes | Checks |Incomes | Incomes |Incomes | Receiving |Payments | Receiving 2 |Payments | Incomes |Payments | Receiving 12 |Payments | Checks |Payments | Incomes |現(xiàn)在我想用相應(yīng)的值替換與列不匹配Incomes或 不匹配的所有內(nèi)容,如下所示:ChecksDesciptionSourceSource | Description |Incomes | Incomes |Incomes | Incomes |Incomes | Checks |Incomes | Incomes |Incomes | Incomes |Payments | Payments |Payments | Incomes |Payments | Payments |Payments | Checks |Payments | Incomes |我該怎么做?我已經(jīng)嘗試df.loc[df['Description'].str.contains('Incomes|Checks')== False] == df['Source']過但沒有成功。提前致謝
熊貓:使用另一列作為源替換值
料青山看我應(yīng)如是
2022-12-06 15:17:08