0

I want to use conditional expression in PyTables where method. In SQL, I would use CASE expression (PostgreSQL, "CASE WHEN a=b THAN 1 ELSE 0"), if usual python, I would use conditional expression "1 if a==b else 0". But I couldn't find how it can be done in PyTables where method.

I checked http://pytables.github.io/usersguide/condition_syntax.html but I don't know if it's possible.

falsetru
  • 357,413
  • 63
  • 732
  • 636
Hyungyong Kim
  • 45
  • 1
  • 5

1 Answers1

1

You can use where(predicate, num1, num2).

table.where('where(a==b, 1, 0) == c')

According to Conditional Syntax

where(bool, number1, number2): number - number1 if the bool condition is true, number2 otherwise.

falsetru
  • 357,413
  • 63
  • 732
  • 636