在df‘the’列中,我希望找到每行字符数最少的单词,并将该值放在df‘’lab‘中。
电流输出
group stem lab
----------------- --------- --------------------- -------------
notif notify, notified nan
face-to-fac face-to-face nan
propo proposed nan
lift lifted nan
govern governed, governing, government, governance nan
constitut constitute, constitutional nan
exp expedient nan
prev preventing, prevent nan
tre treat, treatment nan
work working, works nan预期产出
group stem lab
----------------- --------- --------------------- -------------
notif notify, notified notify
face-to-fac face-to-face face-to-face
propo proposed proposed
lift lifted lifted
govern governed, governing, government, governance governed
constitut constitute, constitutional constitute
exp expedient expedient
prev preventing, prevent prevent
tre treat, treatment treat
work working, works works 试过
df['lab'] = df.stem.str.split(',').apply(lambda x: min(x, key=len))但它的付出
TypeError: 'float' object is not iterable发布于 2019-04-17 15:48:38
https://stackoverflow.com/questions/55731453
复制相似问题