pandas filter on range of values code example
Example: pandas filter on range of values
import pandas as pd
#initialize dataframe
df = pd.DataFrame({'a': [2, 4, 8, 5], 'b': [2, 0, 9, 7]})
#check if the values of df['a'] are in the range(3,6)
out = df['a'].isin(range(3,6))
#filter dataframe
filtered_df = df[out]
print('Original DataFrame\n-------------------\n',df)
print('\nFiltered DataFrame\n-------------------\n',filtered_df)