for i in range(0,len(donor_df)):
if donor_df['cand_nm'][i] == 'Obama, Barack':
donor_df['Party'] = 'Democrat'
else:
donor_df['Party'] = 'Republican'
donor_df
是一个数据框,想要创建一个名为'party'的新列,但没有给出输出
答案 0 :(得分:1)
您正在寻找def func1(i):
return i + 1
def func2(j):
return j + 2
def func3(k):
return k + 3
class test:
def __init__(self, one, two, three):
self.one = one
self.two = two
self.three = three
if __name__ == "__main__":
obj = []
for i in range(10):
if i !=3 and i != 7:
value1 = func1(i)
value2 = func2(i)
value3 = func3(value2)
one1 = value1 + value2
two1 = value1 + value2 + value3
three1 = value1 + value3
obj.append(test(one1, two1, three1))
np.where