我想计算从r到pandas的等价物:
df$received[df$gender == 'F']
在熊猫中,如果我使用:
df['received'][df['gender'] == 'F']
它不起作用。
或者如果我尝试:
df['received'] & df['gender'] == 'F'
它给了我:unsupported operand type(s) for &: 'float' and 'bool'
答案 0 :(得分:1)
您似乎需要loc
与boolean indexing
:
outerbag = load 'file location ' using PigStorage(',') as (eid,edetails);
innerbag = FOREACH outerbag GENERATE eid, FLATTEN(STRSPLIT(edetails,'\t'));
dump innerbag;
样品:
df.loc[df['gender'] == 'F', 'received']