簡體   English   中英

Pandas系列:提取括號之間的文字,包括它們

[英]Pandas Series: Extract text between parenthesis including them

從 pandas 系列中提取文本時,如何包含括號?

my_series.str.extract('\((.*)\)')

如果要在捕獲組中捕獲括號,則需要將轉義的括號放入組中,如下所示:

my_series.str.extract('(\(.*\))')

my_series.str.extract('((.*))') - 刪除轉義字符 / 檢索所有內容(如果需要,則不是部分匹配)。 my_series.str.extract('((\)))') - 僅檢索 )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM