-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?

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
strider0160
  • 519
  • 1
  • 6
  • 15

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)]
U13-Forward
  • 69,221
  • 14
  • 89
  • 114