關於Pandas邏輯運算

從 YTYZX有图有真相的百科
跳到: 導覽搜尋
1. Pandas中用符号 & 表示逻辑与,连接两个逻辑语句,同时为True才为True。不同于Python基本语法中使用 and 表示逻辑与,在Pandas中只能使用 & ,不能用and,否则会报模糊错误。
2. Pandas中用符号 | 表示逻辑或,连接两个逻辑语句,只要其中一个为True就为True。不同于Python基本语法中使用 or 表示逻辑或,在Pandas中只能使用 | ,不能用or。

3. Pandas中用符号 ~ (键盘左上角)表示逻辑非,对逻辑语句取反。不同于Python基本语法中使用 not 表示逻辑非,在Pandas中只能使用 ~ ,不能用not。