Reputation: 45
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.
Upvotes: 0
Views: 169
Reputation: 369284
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.
Upvotes: 1