0

I am filtering my dataframe by the values start with "Rand"

I want to find the opposite which means values do not start with Rant

Here is my code

df_my[df_my["Alg"].str.match("Rand")]

I tried

df_my[not df_my["Alg"].str.match("Rand")]

I get this error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/lib/python3.8/site-packages/pandas/core/generic.py", line 1535, in __nonzero__
    raise ValueError(
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

and

df_my[! df_my["Alg"].str.match("Rand")]

but I got these errors

  File "<stdin>", line 1
    df_my[!df_my["Alg"].str.match("Rand")]
          ^
SyntaxError: invalid syntax

how to get the non match "Rand"

asmgx
  • 7,328
  • 15
  • 82
  • 143

0 Answers0