How to filter dataframe and make a subset at once pandas

前端 未结 2 1174
既然无缘
既然无缘 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条回答
  •  情歌与酒
    2021-01-27 03:10

    Use DataFrame.loc with combination with boolean indexing:

    df.loc[df.colume_4 == some_value, ['col1','col2','col3']]
    

提交回复
热议问题