Ask Question
7 October, 04:52

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. 7 October, 08:40
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers