Python: create a new column from existing columns

前端 未结 6 2048
一生所求
一生所求 2021-02-20 02:48

I am trying to create a new column based on both columns. Say I want to create a new column z, and it should be the value of y when it is not missing and be the value of x when

6条回答
  •  天命终不由人
    2021-02-20 03:08

    I'm not sure if I understand the question, but would this be what you're looking for?

    "if y[i]" will skip if the value is none.

    for i in range(len(x));
        if y[i]:
            z.append(y[i])
        else:
            z.append(x[i])
    

提交回复
热议问题