0

How do I check for a particular range for all columns in a dataframe. After finding the range I would like to return it in a new dataframe. There is the between function for series, but I'm looking for a way to check for a range for all columns. My dataframe is structured like this:

 California    Texas    New York ...
 200000        151000   900000
 50000         160000   250000
 75000         120000   171000
   .              .        .
   .              .        .
   .              .        .

How can I return a dataframe with values in the range 150000-200000 for all columns?

Prog101
  • 109
  • 2
  • 10
  • `df.where(df.apply(lambda x: x.between(150000,200000)))`? NaN where conditions doesn't met – ansev Nov 17 '19 at 20:35
  • 1
    Possible duplicate of [Return dataframe with values in a particular range for all columns](https://stackoverflow.com/questions/58903919/return-dataframe-with-values-in-a-particular-range-for-all-columns) – wwii Nov 17 '19 at 20:44
  • Does this answer your question? [Unable to install pygame on Python 3.8 via pip (Windows 10)](https://stackoverflow.com/questions/58489348/unable-to-install-pygame-on-python-3-8-via-pip-windows-10) – RMPR Nov 17 '19 at 23:06
  • The only way to ensure this is to use NaN where it is not met since all the rows of the frame must have the same length ... or do you want series to be returned? – ansev Nov 18 '19 at 10:36

0 Answers0