这是我的数据框的一部分:
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类,但是我只需要在第一类之后的数据
感谢帮助!
答案 0 :(得分:0)
请检查您是否正在搜索
df.RefactoringDetail.str.extract(r'lass ([^ ]*)')