Jul-14-2019, 09:40 AM
Look at the sample data frame
df = pd.DataFrame({'month': range(12, 0,-1), 'value': pd.np.random.rand(12)})Months countdown from 12 to 1. When we do selection
df[df.month.isin([3,4,5])]the order is retained:
Output: month value
8 5 0.296964
9 4 0.780931
10 3 0.343411