selecting rows based on multiple column values in pandas dataframe

前端 未结 4 715
梦如初夏
梦如初夏 2021-02-12 09:41

I have a pandas DataFrame df:

import pandas as pd

data = {\"Name\": [\"AAAA\", \"BBBB\"],
        \"C1\": [25, 12],
              


        
4条回答
  •  感情败类
    2021-02-12 10:17

    df.query(
        "0 < C1 < 20 and 0 < C2 < 20 and 0 < C3 < 20"
    )
    

    or

    df.query("0 < @df < 20").dropna()
    

    Using @foo in df.query refers to the variable foo in the environment.

提交回复
热议问题