title: Select data frame by dict passing in parameters or comprehension list python pandas
body: <p>I want to select rows in a dataframe passing a dict or a comprehension list. </p>
  
  <p>I have a data frame with millions rows, I want to create a function to select just a part of this data frame corresponding to a list of parameters. To complexity it, I must pass the data frame and the list but this list can contain NaN values and '0'. So I must delete this entry to select the proper rows. </p>
  
  <p>The entry list :</p>
  
  <pre><code>b = ['MUSTANG', 'Coupé', '0', np.nan, np.nan]
  
       AGE    KM     Brand   Model           Liter     Bodycar    Power
  0    2.0  10000.0  FORD    MUSTANG          5.0        Coupé    421
  1    2.0  10000.0  FORD    MUSTANG          5.0        Coupé    421
  2    5.0  10400.0  FORD    MUSTANG          5.0        Coupé    421
  3    5.0  10400.0  FORD    MUSTANG          5.0        Coupé    421
  4   16.0  20700.0  FORD    MUSTANG          3.7        Coupé    317
  5    7.0  23300.0  FORD    MUSTANG          3.7                 317
  6    7.0  23300.0  FORD    MUSTANG          2.3        Coupé    301
  7    7.0  23300.0  FORD    MUSTANG          5.0                 421
  ...
  
  I started a function to remove the part of the list useless and try to select the proper rows but failed... 
  
    def func_mcclbp_incomp(df, mcclbp):
       ind = []
  
       mcclbp = [i if type(i) == str else '0' for i in mcclbp]
       ind = [i for i, x in enumerate(mcclbp) if x=='0']
  
       head = ['Brand','Model','Bodycar','Liter', 'Power']
       mmcclbp = {head[0]:mcclbp[0], head[1]:mcclbp[1], head[2]:mcclbp[2], \
               head[3]:mcclbp[3], head[4]:mcclbp[4]}
       for i in ind:
           del mmcclbp[head[i]]
       df = df[df[head[i]==mccblp[i]] for i in mmcclbp.key()]
       return df
  </code></pre>
  
  <p>I tried a comprehension list but pandas send me an error :</p>
  
  <pre><code>File "&lt;ipython-input-235-6f78e45f59d4&gt;", line 1
  df = df[df[head[i].isin(mccblp[i]) for i in mmcclbp.keys()]]
                                       ^
  SyntaxError: invalid syntax
  </code></pre>
  
  <p>When I tried passing a dict I have a KeyError. </p>
  
  <p>The output needed if I use b is : </p>
  
  <pre><code>     AGE    KM     Brand   Model           Liter     Bodycar    Power
  0    2.0  10000.0  FORD    MUSTANG          5.0        Coupé    421
  1    2.0  10000.0  FORD    MUSTANG          5.0        Coupé    421
  2    5.0  10400.0  FORD    MUSTANG          5.0        Coupé    421
  3    5.0  10400.0  FORD    MUSTANG          5.0        Coupé    421
  4   16.0  20700.0  FORD    MUSTANG          3.7        Coupé    317
  6    7.0  23300.0  FORD    MUSTANG          2.3        Coupé    301
  </code></pre>
  
  <p>If I change b to another value like : </p>
  
  <pre><code>b = ['FORD', 'MUSTANG', 'Coupé', '3.7', '317']
  </code></pre>
  
  <p>The result will be : </p>
  
  <pre><code>     AGE    KM     Brand   Model           Liter     Bodycar    Power
  4   16.0  20700.0  FORD    MUSTANG          3.7        Coupé    317
  </code></pre>
  
  <p>Someone knows how I can select list corresponding rows automatically ? </p>
  
  <p>Thanks for you answer, </p>
  
  <p>Chris.  </p>