根据另一列上的多个条件在Pandas中添加一列

时间:2018-10-09 12:38:36

标签: python pandas numpy

我试图根据Year列中已经存在的值向我的DataFrame添加一个Rk列。我尝试使用下面的代码,但是它将自动将所有值设置为0

df['Year'] = np.where(df['Rk'] <= 540, '2017/2018', 0)
df['Year'] = np.where((df['Rk'] >= 541) & (df['Rk'] <= 1135), '2016/2017', 0)
df['Year'] = np.where((df['Rk'] >= 1136) & (df['Rk'] <= 1713), '2016/2017', 0)

1 个答案:

答案 0 :(得分:2)

cut与指定的垃圾箱一起使用:

public class HumansFragment implenets HumanClick{



@BindView(R.id.recycler_humans)
RecyclerView humansRecyclerView;

@Inject
MyAdapter myAdapter;

.
.
.


public void loadHumans(List<Human> humans) {
    myAdapter.init(Humans, this);
    humansRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    humansRecyclerView.setAdapter(myAdapter);
}


@Override
public void humansClick(Human human) {
        //TODO
}
}