Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Data Science
  3. Question
Data Science

How do I modify the isin python code?

Asked by Claudine Tippins Feb 15, 2023 688 views 1 answer
Share

About this question

Given a list of strings L1 L1 = ['a', 'b', 'c'], I need to extract the rows which contain the values given in list L1. I used the isin function: df[df['column1'].isin(L1)]


The data contains the following values in a column 1:


'a'
'c'
'a, d'
'brp'

The data contains the following values in a column 2:


['a']
['c']
['a', 'd']
['brp']

The output I need should print all the rows because the string 'a' is present in L1, but, the output returns only 3 rows: rows 1, 2 (that is the rows containing strings 'a', 'c')


How do I modify the code so that it returns the 3rd row as well?

Your answer

1 Answer

More Data Science discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Data Science Blogs

Guides, tips and career advice on Data Science from JanBask experts.