如果:
sum(list(map(lambda x : sum(len(y) for y in x.split()), df['column2'].iloc[3])))
获取数据帧中第2列第3行的总字符df,然后如何查找具有特定总字符数的列(例如:哪个索引列的总字符数为43382)
已编辑: 我尝试了这个相当长的代码:
df.loc[df['column2'] == (sum(list(map(lambda x : sum(len(y) for y in x.split()), df['column2'])))).isin('43382')]
但我收到了错误信息:
AttributeError: 'int' object has no attribute 'isin'
这就是我的数据帧df的样子”
column1 column2 column3
amsterdam school yeah right backtic escapes sport swimming 2016
rotterdam nope yeah 2012
thehague i now i can fly no you cannot swimming rope 2010
amsterdam sport cycling in the winter makes me 2019
我通过对每行的所有字符求和并将其返回到一个新列=column4,计算出了它:
然后简单地用下面的代码查看欲望角色的总计数:
你能试试吗
希望这有帮助
请尝试改用
eq
:相关问题 更多 >
编程相关推荐