Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 是否使用for循环在pandas中创建新列?_Python 3.x_Pandas_For Loop - Fatal编程技术网

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'