[Python] how to search for multiple substrings in a column using polars

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    In pandas, I can search for multiple different substrings in a column, and determine which rows they can be found in. How can I do this in polars?

    my pandas code:

    df = pd.DataFrame({'col1':['a red','dog','liked to play','with his best friend','the CAT']})
    ls = ['best','dog']
    df[df.col1.str.contains('|'.join(ls))]

    Continue reading...

Compartilhe esta Página