How to filter dataframe and make a subset at once pandas

前端 未结 2 1182
既然无缘
既然无缘 2021-01-27 03:05

I am trying to make a subselection of a dataframe based on some columns, while at the same time filtering the dataframe based on a different column. In SQL it looks like this:

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-27 03:28

    An alternative way:

    df[df['col4']==3].filter(['col1', 'col2', 'col3'])
    

提交回复
热议问题