Python: UserWarning: This pattern has match groups. To actually get the groups, use str.extract

前端 未结 5 2212
隐瞒了意图╮
隐瞒了意图╮ 2020-12-09 16:17

I have a dataframe and I try to get string, where on of column contain some string Df looks like

member_id,event_path,event_time,event_duration
30595,\"2016-         


        
5条回答
  •  温柔的废话
    2020-12-09 16:54

    Since regex=True is provided, sublist gets treated as a regex, which in your case contains capturing groups (strings enclosed with parentheses).

    You get the warning because if you want to capture something then there is no use of str.contains (which returns boolean depending upon whether the provided pattern is contained within the string or not)

    Obviously, you can suppress the warnings but it's better to fix them.

    Either escape the parenthesis blocks or use str.extract if you really want to capture something.

提交回复
热议问题