9951 explained code solutions for 126 technologies


python-pandasSelect dataframe rows between two values


import pandas as pd

df = pd.DataFrame({
  'phone': ['ip5', 'ip6', 'ip8', 'sms', 'xi'],
  'price': [204, 304, 404, 405, 305]
})

found = df[df['price'].between(300,400)]ctrl + c
import pandas as pd

load Pandas module

pd.DataFrame

creates Pandas DataFrame object

.between(300,400)

finds rows with price value between 300 and 400

found

will contain filtered dataframe