0

Trying to query the DataFrame for only the rows under the 'Products' column that contain the string 'Microsoft'. The string 'Microsoft' appears as a standalone cell value as well as a comma-separated value in certain cells.

Query function worked before but now it's giving TypeError:

df = df.query("Products.str.contains('Eloqua', case=False)")

1
  • df["Products"].dtype returns Object and df["Products"].isna().sum() returns 0. Whats odd is above query worked before. I restarted the kernel a few times without any success. Commented Feb 7, 2023 at 3:26

1 Answer 1

1

If df["Products"].dtype returns "Object" following should do it.

df = df[df.Products.str.contains('Microsoft', case = False)]
Sign up to request clarification or add additional context in comments.

1 Comment

that did it, thanks. Still cant understand why the query failed tho.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.