-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
  • 14,712
  • 2
  • 33
  • 62
progster
  • 797
  • 2
  • 11
  • 23

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
  • 1,792
  • 1
  • 14
  • 25