Ask Question
18 December, 11:43

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.

+5
Answers (1)
  1. 18 December, 13:04
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers