-1

I have a pandas dataframe that looks like this:

Pandas dataframe

From this, I want to grab all the rows for particular Filters (1st column). So for example, I want to grab the rows for F218W, F336W, and F373N.

What is the easiest way to do this in pandas?

In addition if I wanted to grab the rows for those filters but also only for Chip 1, how could I do that easily?

Thanks!

ProtonChain
  • 121
  • 2
  • 10

1 Answers1

1

This is a simple slicing:

df[df["# Filter"].isin(["F218W", "F336W","F373N"])]

If the rules across multiple columns, you can simply combine them using &:

df[df["# Filter"].isin(["F218W", "F336W","F373N"]) & (df["Chip"] == 1)]
TYZ
  • 8,466
  • 5
  • 29
  • 60