Python 3.x 是否使用for循环在pandas中创建新列?
我想使用来自另一列的多个值的组合在数据框中创建一个新列 我尝试了以下代码,但似乎不起作用。接线员不在工作,我看得出来Python 3.x 是否使用for循环在pandas中创建新列?,python-3.x,pandas,for-loop,Python 3.x,Pandas,For Loop,我想使用来自另一列的多个值的组合在数据框中创建一个新列 我尝试了以下代码,但似乎不起作用。接线员不在工作,我看得出来 enter code here lst = [df1] for column in lst: column.loc[(column["booking_text"] in ['SEPA-Gutschrift','SEPA-Cash Management Gutsch','FASTER PAYMENTS','SCHECK-EV','BACS CREDIT',
enter code here
lst = [df1]
for column in lst:
column.loc[(column["booking_text"] in ['SEPA-Gutschrift','SEPA-Cash
Management Gutsch','FASTER PAYMENTS','SCHECK-EV','BACS CREDIT','POS
Gutschrift','Scheckeinreichung e.V.'])
& (column["debit_credit"] == 'Credit'), "financial_category"] = 'Reveunue_Credit'
df1['financial_category'] = df1['financial_category']
ValueError:序列的真值不明确。使用a.empty、a.bool()、a.item()、a.any()或a.all()
lst = [df1]
for column in lst:
column.loc[(column["booking_text"].isin(['SEPA-Gutschrift','SEPA-Cash Management
Gutsch','FASTER PAYMENTS', 'SCHECK-EV','BACS CREDIT','POS
Gutschrift','Scheckeinreichung e.V.'])) & (column["debit_credit"] == 'Credit'), 'financial_category'] = 'Reveunue_Credit'