Format: text/x-python
⬇ Download File (599 B)
   1  # -*- coding: utf-8 -*-
   2  """
   3  Created on Sat May 22 16:58:44 2021
   4  
   5  @author: PC
   6  """
   7  
   8  import pandas as pd
   9  import os
  10  
  11  os.chdir(r'C:\Users\PC\Pytho')
  12  
  13  df= pd.read_csv('NISPUF17.csv')
  14  
  15  def proportion_of_education():
  16      df= pd.read_csv('NISPUF17.csv', index_col=0)
  17      result= {'less than high school': df['EDUC1'].value_counts()[1]/len(df),
  18               'high school' : df['EDUC1'].value_counts()[2]/len(df),
  19               'more than high school' : df['EDUC1'].value_counts()[3]/len(df),
  20               'college' : df['EDUC1'].value_counts()[4]/len(df)
  21               }
  22      return result
  23