l = df.b.dropna().values # grab values from b
# double comprehension
a = np.array([[j in i for i in l] for j in l])
# of course strings are sub-strings of themselves
# lets ignore them by making the diagonal `False`
np.fill_diagonal(a, False)
# find the indices where the array is `True`
i, j = np.where(a)
l[i].tolist()
['world', 'ness']
如果行索引是列标题的子字符串,我们可以创建一个真值数组。在
我觉得更好
^{pr2}$您可以使用:
交叉连接的替代解决方案:
^{pr2}$这可能对您有用:
相关问题 更多 >
编程相关推荐