pandas - Pandas: Applying '&' operator in df.query(), in mutiindex scenario
问题描述
How to use the &
operator in df.query()
for same index in multi-index
data frame. e.g in my data frame named 'movie_genre'.
I have three indexes -> [id, title, genre]
. Now I want to access all the id & title wherein genre is 'Comedy' & 'Drama'. I am using
df.query('(genre=="Comedy") & (genre=="Drama")')
but it is returning blank result.
解决方案
推荐阅读
- sql - 使用 Group By 不工作的分桶值?
- python - Lo Shu Magic Square - 一直显示'false'未定义然后无效
- javascript - 为什么 ActionCable 会多次渲染局部?
- swift - StackView 中的按钮约束(以 Swift 编程方式)
- python-c-api - 如何将 python 2 C 扩展模块转换为 python 3
- django - 可以对内置的注册和登录系统进行小改动吗?
- variables - Sass:变量选择器名称作为值。(后缀)
- java - 使用子类中的 toString() 方法
- javascript - 更新列表后在 iOS 上滚动列表失败 - 需要再次模糊和聚焦
- mysql - 在不使用笛卡尔连接的情况下组合许多 sql 查询的结果