我有2个数据帧,CompConfig:
days recent_days min_conf_level_firs_iteration min_user_active_days
0 1 7 0.8 10
和local_users:
clienthostid score siduser
0 1 1728 1
1 1 1331 2
3 1 125 3
4 1 216 4
2 3 1000 5
5 3 512 6
根据clienthostid,我想让所有siduser得分除以SumOfScores大于min_conf_level_firs_iteration。
我做:
min_conf_level_firs_iteration = \
CompConfig.loc[0, 'min_conf_level_firs_iteration'].astype(float)
local_users.groupby(
['clienthostid'], sort=False
)['score'].apply(
lambda x: min_conf_level_firs_iteration > (x / local_users['score'].sum()))
我收到错误:
if len(self)!= len(other):TypeError:未确定对象的len()
但是如果我用0.8尝试它就可以了:
local_users.groupby(['clienthostid'], sort=False)['score'].apply(lambda x: 0.8 > (x / local_users['score'].sum()))
是否因为我获得min_conf_level_firs_iteration的方式?我以为我把它作为常数... 我是Python和Pandas的新手,如果问题有点明显,那就很抱歉
谢谢