-1

I can't figure it out why this does not work. The df2 dataframe should contain all the data from df which match two conditions..

df2 = df.loc[df['area'] == "north" & df['product'] == "a"]
Ma0
  • 15,057
  • 4
  • 35
  • 65
progster
  • 877
  • 3
  • 15
  • 27

1 Answers1

0

Either

df2=df.loc[df['area'] == "north"].loc[df['product'] == "a"]

or

df2 = df[(df["area"] == "north") & (df["product"] == "a")]

Would do the job.

danielhadar
  • 2,031
  • 1
  • 16
  • 27