1

I have a list of boolean conditions with pandas/numpy. For example

cond1 = x > 5
cond2 = x > 6
cond3 = x > 8
...
list_conds = [cond1, cond2, cond3, ...]

I want to mix them to produce the condition

cond1 & cond2 & cond3 & ...

How can I get this?

AMC
  • 2,642
  • 7
  • 13
  • 35
Vladimir Vargas
  • 1,744
  • 4
  • 24
  • 48
  • 2
    `all(list_conds)` – dcg Apr 26 '20 at 01:13
  • 1
    What is the issue, exactly? Have you tried anything, done any research? Please see [ask], [help/on-topic]. – AMC Apr 26 '20 at 02:26
  • Does this answer your question? [JSON to pandas DataFrame](https://stackoverflow.com/questions/21104592/json-to-pandas-dataframe) – AMC Apr 26 '20 at 02:27

1 Answers1

1

You can use the all() function which will check that all the items in the iterable are true, so all(list_conds) for built-in python or numpy's all() https://docs.scipy.org/doc/numpy/reference/generated/numpy.all.html or pandas dataframe all() https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.all.html

seanpue
  • 313
  • 1
  • 7