[英]Python: Finding a value in 1 list and finding that corresponding index in another list
[英]Finding list of index corresponding to list of element of a dataframe in Python
我有一个包含数百万行的数据帧。 我需要获取原始数据帧中存在的数十万个元素的相应索引。
我目前使用此代码:
df[df['processed_col'] == element.index[0]
找到'element'
在整个数据框中的位置。
有没有办法把一个像element1, element2,..., elementN
这样的列表作为输入,这将返回一个相应索引的列表:
df[df['processed_col'] == [element1, element2, ..., elementN].index[0]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.