Ask Question
14 December, 22:14

python Create a new qualitative variable, called Elite, by binning the Top10perc variable. We are going to divide universities into two groups based on whether or not the proportion of students coming from the top 10% of their high school classes exceeds 50.

+3
Answers (1)
  1. 14 December, 22:39
    0
    import pandas as pd

    # URL for university excel sheet (CSV format)

    data_url = '' "

    # Load the data from University URL

    university = pd. read_csv (data_url)

    # filter the data to contain universities from where more than 50 students out of the top 10% of their high school classes came

    university_1 = university[universty. number>50 ]

    n = len (university_1)

    n1 = (10 * n) / 100

    university_1. nlargest (n1, 'number')

    print (university_1)

    Explanation:

    We are using here Pandas. And it is meant for reading from various data sources like Excel, Acess, SQL Server, etc. And first, we filter University with student number more than or equal to 50. Finally, with the nlargest, we find the top 10% of the list. And for running the above program we only need to add the URL of the university. csv. Nothing else is required. You can have the local file address as well if the CSV is on your computer.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “python Create a new qualitative variable, called Elite, by binning the Top10perc variable. We are going to divide universities into two ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers