Finding Different Values in Same Column

  pandas, python

Say I had a column called ‘Letters’ which had A to Z as its values, how would I find rows where only X and Y occur?

If it was just X I know I could use this code:

df.loc[df['Letters'] == 'X']

But how do I expand that for X and Y (or even more letters if needed)?

Source: Python Questions

LEAVE A COMMENT