我有一个pandas.DataFrame
:
index question_id tag
0 1858 [pset3, game-of-fifteen]
1 2409 [pset4]
2 4346 [pset6, cs50submit]
3 9139 [pset8, pset5, gradebook]
4 9631 [pset4, recover]
我需要从tag
列的字符串列表中删除除pset*
字符串之外的所有字符串。在
所以我要用这样的话来结束:
^{pr2}$
请问我该怎么做?在
Tags:
您可以将函数应用于
tag
系列,该系列只使用以'pset'
开头的元素构造列表您甚至可以在operator中使用python
一个选项:使用
apply
方法循环检查tag
列中的项;对于每个项,使用列表理解根据前缀使用startswith
方法过滤字符串:相关问题 更多 >
编程相关推荐