I have this dataframe:
my_df = pd.DataFrame({
'A': 'a0,a1,a2,a3'.split(','),
'B': 'b0,b1,b2,b3'.split(','),
'price': [100, 10, 50, 500]
})
A B price
0 a0 b0 100
1 a1 b1 10
2 a2 b2 50
3 a3 b3 500
I can use this piece of code to subsample the rows of the top 90 percent prices.
q_90 = my_df['price'].quantile(q=0.9)
my_df[my_df['price'] >= q_90]
A B price
3 a3 b3 500
I am wondering does pandas data frame has any method to do it with higher speed performance directly such as:
my_df.some_method(q=0.9)
A B price
3 a3 b3 500