0

I would like to get the row index of the row that contains certain values(more than one).

I have tried put the values that I would like to retrieve in a list but failed, I can only search the index one by one which is quite tedious.

Possible but tedious

rows.loc[rows['NO']=='NO'].index.values
rows.loc[rows['NO']=='Sub Total :'].index.values
rows.loc[rows['NO']=='Generated By:'].index.values
rows.loc[rows['NO']=='Product :'].index.values

Failed

rows.loc[rows['NO']==list1].index.values
0

2 Answers 2

1

Try this

rows.loc[rows['NO'].isin(list1)].index.values
Sign up to request clarification or add additional context in comments.

Comments

1

Use str.contains as:

l = ['NO','Sub Total :', 'Generated By:', 'Product :']
index = rows.loc[rows['NO'].str.contains('|'.join(l)), 'NO'].index.values

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.