How to filter data in python

前端 未结 1 1642
慢半拍i
慢半拍i 2021-01-29 14:12

I have a data set like d1.

import pandas as pd
d1 = {
\'customers\': pd.Series([1, 1, 1, 2, 2, 3, 3, 4, 4]),
\'channel\': pd.Series([\'a\', \'a\', \         


        
相关标签:
1条回答
  • 2021-01-29 14:54

    Is this what you want ?

    d1[d1.customers.isin(d1[(d1.freq==2) & (d1.channel=="a")].customers)]
    
      channel  customers  freq
    3       c          2     2
    4       a          2     2
    5       a          3     2
    6       b          3     2
    

    HTH

    0 讨论(0)
提交回复
热议问题