错误:
#筛选10、11月的自行车数据,赋值变量为gather_customer_order_10_11
gather_customer_order_10_11=\
gather_customer_order[gather_customer_order['create_year_month1']=='2019-10'|gather_customer_order['create_year_month1']=='2019-11']


原因解释:
出现这个问题的原因在于运算优先级的问题,‘|’的元素优先级高于‘==’,所以要加括号,修改如下:
#筛选10、11月的自行车数据,赋值变量为gather_customer_order_10_11
gather_customer_order_10_11=gather_customer_order[(gather_customer_order['create_year_month1']=='2019-10')|(gather_customer_order['create_year_month1']=='2019-11')]
补充:
以下所列优先级顺序按照从低到高优先级的顺序(同行为相同优先级,相同优先级按从左到右的顺序运算):
Lambda #运算优先级最低
逻辑运算符: or
逻辑运算符: and
逻辑运算符:not
成员测试: in, not in
同一性测试: is, is not
比较: <,<=,>,>=,!=,==
按位或: |
按位异或: ^
按位与: &
移位: << ,>>
加法与减法: + ,-
乘法、除法与取余: *, / ,%
正负号: +x,-x
网友评论