[英]df.loc with more than one condition
I am trying to produce a variable in my dataframe that states if the specfied time is in rush hour using two other variables 'hour' and 'weekday?'.When I run the code it only states 'NaN', can someone guide me on what is wrong with my code?我正在尝试在我的 dataframe 中生成一个变量,该变量使用另外两个变量“小时”和“工作日”来说明指定时间是否处于高峰时段?当我运行代码时它只显示“NaN”,有人可以指导我吗我的代码有什么问题? The code that i am using can be seen below:
我正在使用的代码如下所示:
df.loc[(df['hour'] <7) & (df['hour']>10) & (df['hour'] <3) & (df['hour']>6) , 'Rush_hour?'] = 'No'
df.loc[(df['hour'] >=3) & (df['hour']<=6) & (df['weekday?'] == 'yes'), 'Rush_hour?'] = ' Yes-pm' ```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.