python “int”对象不可订阅

dsekswqp  于 2022-12-28  发布在  Python
关注(0)|答案(1)|浏览(143)
control1 = [933, 1101, 471, 577, 507, 1124, 1354, 1754, 18591, 11327, 10140, 1021769]
ct1 = [33, 101, 472,5077, 9507, 1124, 13584, 1574, 18591, 10327, 10140, 10276, 10635, 13366, 10480, 103961, 103979, 1047]
def control_treatment(dataset):
  vals = dataset[dataset["account_id"].isin(ct1)]
  vals= vals.withColumn("account_id", vals["account_id"].cast(IntegerType()))
  if vals[vals['account_id'].isin(control)]:
    return 1
  else:
    return 0
  return control_treatment

我需要一个返回1和0的伪值的列。因此,当ct1的帐户ID位于/matches control1中时,创建的新列应该为1,否则为0

wgmfuz8q

wgmfuz8q1#

dataset["control_treatment"] = dataset["account_id"].isin(ct1).astype(int)

相关问题