Advertisement
elena1234

get the bottom half of the column in Python

Apr 30th, 2022
954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. import numpy as np
  2. import pandas as pd
  3. import seaborn as sns
  4. import matplotlib.pyplot as plt
  5.  
  6.  
  7. df = pd.read_csv('C:/Users/eli/Desktop/application_record.csv')
  8. plt.figure(figsize=(12,5))
  9. bottom_half_income = df.nsmallest(n=int(0.5*len(df)),columns='AMT_INCOME_TOTAL')
  10.  
  11. box_plot = sns.boxplot(x ='NAME_FAMILY_STATUS', y = 'AMT_INCOME_TOTAL', data = bottom_half_income, hue ='FLAG_OWN_REALTY', linewidth=3)
  12. plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.,title='FLAG_OWN_REALTY')
  13. plt.title('Income Totals per Family Status for Bottom Half of Earners')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement