[英]How to extract specific String from rows of a dataframe?
这是我的数据帧的一部分:
RefactoringDetail
"Pull Up Attribute protected steps : int from class blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm to class blokusgame.mi.android.hazi.blokus.GameLogic.Player"
"Pull Up Attribute protected steps : int from class blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm to class blokusgame.mi.android.hazi.blokus.GameLogic.Player"
"Pull Up Attribute protected steps : int from class blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm to class blokusgame.mi.android.hazi.blokus.GameLogic.Player"
"Move Class GameLogic.PlayerHuman moved to blokusgame.mi.android.hazi.blokus.GameLogic.PlayerHuman"
我只需要这部分:
blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm
blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm
blokusgame.mi.android.hazi.blokus.GameLogic.PlayerAlgorithm
GameLogic.PlayerHuman
这是我的代码:
import pandas as pd
df = pd.read_csv('result_refactorings.csv', sep=';')
refactoring_details = df['RefactoringDetail']
print(refactoring_details)
a=refactoring_details.to_frame(name=None)
然后从数据框中提取我需要的东西,我试图使用子字符串,但它不起作用
for elem in a:
s = substring.substringByChar("elem", startChar="c", endChar="n")
我尝试在String类之后提取数据,然后我发现在同一行中我有2个Strings类但我只需要第一个类之后的数据
感谢帮助 !
请检查您是否正在搜索
df.RefactoringDetail.str.extract(r'lass ([^ ]*)')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.