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.

4

1 回答 1

1

您可以使用where(predicate, num1, num2).

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

根据条件语法

where(bool, number1, number2): number - 如果布尔条件为真,则为 number1,否则为 number2。

于 2013-07-31T13:19:42.660 回答