-1

I was trying to find records based on two conditions on a data frame preg

First:

preg[preg.caseid==2298 & preg.pregordr==1]

This throws and error that truth value of a series is ambiguous. Why?

Second: But this one works!

preg[(preg.caseid==2298) & (preg.pregordr==1)]

So what exactly is the difference between the two?

U12-Forward
  • 65,118
  • 12
  • 70
  • 89
strider0160
  • 419
  • 5
  • 11

1 Answers1

2

Because it thinks that you're doing 2298 & preg.pregordr something like that, without parenthesis you can do:

preg[preg.caseid.eq(2298) & preg.pregordr.eq(1)]
U12-Forward
  • 65,118
  • 12
  • 70
  • 89