For循环不起作用

时间:2017-03-30 08:46:31

标签: python

我需要将列值乘以另一个数据帧的值。 为了实现这一点,我使用applymap,但它没有按预期工作。

def testfunc(x):
    # if x is a string,
    if type(x) is str:
        # just return it untouched
        return x
    # but, if not, return it with range
    elif x:
        for number in range(3):
            return x * pp[number]

print(f.applymap(testfunc))

不幸的是,x单独乘以一个值,它没有考虑其他值。我的意思是,我的预期输出应该是这样的

x*dataframe[0]-----This one alone is considered while using applymap
x*dataframe[1]-----this is being ignored
x*dataframe[2]-----This is being ignored.

0 个答案:

没有答案