Selecting rows from a Dataframe based on values in multiple columns in pandas

前端 未结 2 1604
星月不相逢
星月不相逢 2020-12-14 11:48

This question is very related to another, and I\'ll even use the example from the very helpful accepted solution on that question. Here\'s the example from the acce

2条回答
  •  再見小時候
    2020-12-14 12:09

    You can do this with tiny altering in your code:

    print(df[df['A'] == 'foo'][df['B'] == 'one'])
    

    Output:

         A    B  C   D
    0  foo  one  0   0
    6  foo  one  6  12
    

提交回复
热议问题