0

I have a pandas Dataframe and i only want to select the rows if the 'code' is available in my set. I am currently trying this:

country_codes = set(set(dle['Code']) & set(dgdp['Code']))
dgdp.loc[dgdp['Code'].str in country_codes]

or

dgdp.loc[dgdp['Code'] in country_codes]

On the second one I get the problem TypeError: 'Series' objects are mutable, thus they cannot be hashed and in the first one I get KeyError: False.

How can I get the info for the codes that I want?

1 Answer 1

1

try: dgdp.loc[dgdp['Code'].isin(country_codes)]

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.