df.loc[(df[“height”]>=180) & (df[“weight”]>=80),“xinlie”]=“high”
df.loc[(df[“height”]<=180) & (df[“height”]>=170) &(df[“weight”]<=80) & (df[“weight”]>=70),“xinlie”]=“msize”
df.loc[~(((df[“height”]>=180) & (df[“weight”]>=80)) | ((df[“height”]<=180) & (df[“height”]>=170) &(df[“weight”]<=80) & (df[“weight”]>=70))),“xinlie”]=“small”
使用loc进行数据过滤
最新推荐文章于 2023-11-30 09:50:28 发布