Advertisement
elena1234

slice dataframe by top 20 percent in Python

Mar 3rd, 2023 (edited)
984
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.18 KB | Source Code | 0 0
  1. top_20_percent = df.iloc[df[column].nlargest(int(len(df) * 0.2))]
  2.  
  3. *******************************************
  4.  
  5. top_20_percent = df.nlargest(int(len(df) * 0.2), columns='column_name')
  6.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement