0

I am using this dataset to try and make a dynamic bubble graph but I came across an issue. When I search for the genre eg Western it searches for exactly that string. The problem is that 'dataset_by_year["genre"]' holds genres with multiple genres (e.g. western, comedy, action), which is not matched.

for genre in genres:
    dataset_by_year = BubbleGV[BubbleGV["year"] == year1]
    dataset_by_year_and_cont = dataset_by_year[
        dataset_by_year["genre"] == genre]

All I want to do is to search for the genre within the multiple genres and match the string.

Any help would be greatly appreciated.

1
  • So how exactly are those stored? Is it a list of strings, a string containing comma-separated values, or something else? Commented Nov 1, 2020 at 12:12

1 Answer 1

1

Sorry didn't check with your full data try this, it might work:

dataset_by_year_and_cont = dataset_by_year[dataset_by_year["genre"].str.contains(genre)]
Sign up to request clarification or add additional context in comments.

Comments

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.