admin管理员组

文章数量:1599533

pandas使用apply函数基于条件(if condition)生成新的数据列

目录

pandas使用apply函数基于条件(if condition)生成新的数据列

#df.loc方法数值判断生成新的列

#apply+ifelse数值判断生成新的数据列

#df.loc方法字符判断生成新的列

#apply+ifelse字符判断生成新的数据列

#df.loc方法组合条件判断生成新的列

#apply+ifelse组合条件判断生成新的数据列


#df.loc方法数值判断生成新的列

df.loc[df['column name'] condition, 'new column name'] = 'value if condition is met'

import pandas as pd

numbers = {'set_of_numbers': [1,2,3,4,5,6,7,8,

本文标签: 函数条件数据pandasapply