私はすべてのリターンマッチを与えられた範囲で取得するために私のコードを使いこなしています。私のデータサンプルは、次のとおりです。正規表現を使って与えられた範囲で結果を一致させるには?
comment
0 [intj74, you're, whipping, people, is, a, grea...
1 [home, near, kcil2, meniaga, who, intj47, a, l...
2 [thematic, budget, kasi, smooth, sweep]
3 [budget, 2, intj69, most, people, think, of, e...
私は結果を取得したいと:私のコードがある(与えられた範囲はintj75するintj1です)
comment
0 [intj74]
1 [intj47]
2 [nan]
3 [intj69]
:
df.comment = df.comment.apply(lambda x: [t for t in x if t=='intj74'])
df.ix[df.comment.apply(len) == 0, 'comment'] = [[np.nan]]
私は」正規表現を使ってt == 'range'の範囲を見つける方法がわかりません。これを行う他のアイデアか?事前に
おかげで、
パンダのPython初心者
'intj \ d +'は、その後に1つ以上の数字が続く 'intj'にマッチします。 – Maroun
@Maroun Marounは返信してくれてありがとう。残念ながら、それは動作していません。あなたの提案をどのように正確に適用するには? –