Using pandas, I need to calculate the average HDI for each category. The category is based...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Using pandas, I need to calculate the average HDI for each category. The category is based off of the HDI Tier. There are 5 categories: "Very High", "High", "Medium", "Low", and "not rate". hdiTier hdi2021 Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High 0.962 0.961 0.959 0.952 0.951 0.948 0.947 0.945 0.942 0.941 0.94 0.939 0.937 0.937 0.936 0.935 0.93 0.929 0.925 0.925 0.921 0.919 0.918 0.918 0.916 hdi2020 hdi2019 hdi 2010 hdi2000 0.942 0.941 0.902 0.907 0.923 0.913 0.91 0.904 0.926 0.917 0.911 0.91 0.912 0.922 0.911 0.913 0.912 0.912 0.956 0.959 0.957 0.949 0.952 0.947 0.941 0.947 0.946 0.942 0.947 0.943 0.942 0.944 0.948 0.939 0.943 0.938 0.939 0.939 0.943 0.928 0.936 0.936 0.937 0.931 0.937 0.933 0.94 0.924 0.927 0.924 0.935 0.923 0.924 0.922 0.923 0.92 0.93 0.917 0.921 0.913 0.921 0.911 0.915 0.913 0.919 0.962 0.961 0.96 0.898 0.89 0.911 0.894 0.89 0.861 0.902 0.887 0.913 0.871 0.851 0.896 0.889 0.904 0.847 0.889 0.893 0.891 0.831 0.887 0.887 0.89 0.873 0.864 0.862 0.877 0.825 0.891 0.844 0.821 0.779 0.871 Original Code import pandas as pd from selenium import webdriver from selenium.webdriver.common.by from selenium.webdriver.chrome.service import Service from selenium.webdriver.support.ui import WebDriverwait from selenium.webdriver.support import expected_conditions as EC #chrome driver has been downloaded and installed onto computer for use with selenium. serv_obj = Service ("C:\\Users\\USERNAME\\Desktop\\chromedriver.exe") driver = webdriver.Chrome (service=serv_obj) # Website URL import By driver.get("https://worldpopulationreview.com/country-rankings/hdi-by-country") # Wait for the website to load. wait = WebDriverwait (driver, 10) #There is a pop-up window that needs to be closed driver.find_element(By.XPATH, '//html/body/div[3]/div/div[1]/button').click() #let's wait for the page to load and find the xpath to the table we want to scrape xpath = '//*@id="_next"]/div/div[3]/section [3]/div[1]/div/div[1]/div[1]/div[2]' table = wait.until (EC.presence_of_element_located ((By.XPATH, xpath))) # Find all the rows in the table rows = table.find_elements (By.XPATH, "//tbody/tr") # Empty list to store the data data = [] # Iterate over each row for row in rows: # Find all the cells in the row cells = row.find_elements (By.XPATH, "td") # Append the text of each cell to the data list data.append([cell.text for cell in cells]) # Dataframe from the data list column_names = ["Country", "HDI tier", "HDI 2021", "2023 Population", "HDI 2020", "HDI 2019", "HDI 2018", "HDI 2000", "Avg. Annual HDI growth 1998-2021"] df = pd.DataFrame (data, columns=column_names) print (df) Using pandas, I need to calculate the average HDI for each category. The category is based off of the HDI Tier. There are 5 categories: "Very High", "High", "Medium", "Low", and "not rate". hdiTier hdi2021 Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High Very High 0.962 0.961 0.959 0.952 0.951 0.948 0.947 0.945 0.942 0.941 0.94 0.939 0.937 0.937 0.936 0.935 0.93 0.929 0.925 0.925 0.921 0.919 0.918 0.918 0.916 hdi2020 hdi2019 hdi 2010 hdi2000 0.942 0.941 0.902 0.907 0.923 0.913 0.91 0.904 0.926 0.917 0.911 0.91 0.912 0.922 0.911 0.913 0.912 0.912 0.956 0.959 0.957 0.949 0.952 0.947 0.941 0.947 0.946 0.942 0.947 0.943 0.942 0.944 0.948 0.939 0.943 0.938 0.939 0.939 0.943 0.928 0.936 0.936 0.937 0.931 0.937 0.933 0.94 0.924 0.927 0.924 0.935 0.923 0.924 0.922 0.923 0.92 0.93 0.917 0.921 0.913 0.921 0.911 0.915 0.913 0.919 0.962 0.961 0.96 0.898 0.89 0.911 0.894 0.89 0.861 0.902 0.887 0.913 0.871 0.851 0.896 0.889 0.904 0.847 0.889 0.893 0.891 0.831 0.887 0.887 0.89 0.873 0.864 0.862 0.877 0.825 0.891 0.844 0.821 0.779 0.871 Original Code import pandas as pd from selenium import webdriver from selenium.webdriver.common.by from selenium.webdriver.chrome.service import Service from selenium.webdriver.support.ui import WebDriverwait from selenium.webdriver.support import expected_conditions as EC #chrome driver has been downloaded and installed onto computer for use with selenium. serv_obj = Service ("C:\\Users\\USERNAME\\Desktop\\chromedriver.exe") driver = webdriver.Chrome (service=serv_obj) # Website URL import By driver.get("https://worldpopulationreview.com/country-rankings/hdi-by-country") # Wait for the website to load. wait = WebDriverwait (driver, 10) #There is a pop-up window that needs to be closed driver.find_element(By.XPATH, '//html/body/div[3]/div/div[1]/button').click() #let's wait for the page to load and find the xpath to the table we want to scrape xpath = '//*@id="_next"]/div/div[3]/section [3]/div[1]/div/div[1]/div[1]/div[2]' table = wait.until (EC.presence_of_element_located ((By.XPATH, xpath))) # Find all the rows in the table rows = table.find_elements (By.XPATH, "//tbody/tr") # Empty list to store the data data = [] # Iterate over each row for row in rows: # Find all the cells in the row cells = row.find_elements (By.XPATH, "td") # Append the text of each cell to the data list data.append([cell.text for cell in cells]) # Dataframe from the data list column_names = ["Country", "HDI tier", "HDI 2021", "2023 Population", "HDI 2020", "HDI 2019", "HDI 2018", "HDI 2000", "Avg. Annual HDI growth 1998-2021"] df = pd.DataFrame (data, columns=column_names) print (df)
Expert Answer:
Answer rating: 100% (QA)
To calculate the average HDI for each category you can use the Pandas library First you need to preprocess the data to make sure the HDI values are nu... View the full answer
Related Book For
Applied Regression Analysis and Other Multivariable Methods
ISBN: 978-1285051086
5th edition
Authors: David G. Kleinbaum, Lawrence L. Kupper, Azhar Nizam, Eli S. Rosenberg
Posted Date:
Students also viewed these programming questions
-
You wish to check your luggage for a flight. However, the scale at the airport is broken. You found a spring that obeys Hooke's Law hanging off the wall. Assume the spring is weightless. You hang a...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
A circular plate of radius a and mass m supported by a ball-and-socket joint at point A is rotating about the y axis with a constant angular velocity = 0j when an obstruction is suddenly introduced...
-
The following selected events were experienced by either Cardinal Industries, Inc., a corporation, or Larry Cardinal, the major stockholder. State whether each event (1) Increased, (2) Decreased, (3)...
-
What are some potential disadvantages of using a packaged application to help automate the employee goal-setting process?
-
Consider the piston ring data shown in Table 6.3. Assume that the specifications on this component are 74.000 ï±ï 0.05 mm. (a) Set up x and R control charts on this process. Is the...
-
An 80.0 kg sprinter starts a race with an acceleration of 1.96 m/s2. If the sprinter accelerates at that rate for 34 m, and then maintains that velocity for the remainder of the 100 m dash, what will...
-
Evaluate the following statements by providing a brief explanation or analysis. (a) The income gap ratio and the head count, as measures of poverty, may lead to very different uses of antipoverty...
-
The following information was taken from the accounting records of Pembina Manufacturing Limited, which has recently come under the jurisdiction of a licensed trustee in bankruptcy: Carrying amount...
-
What ethical considerations arise in the context of respiratory research and clinical interventions, particularly concerning issues like access to healthcare, environmental justice, and the equitable...
-
1. Determine the amount of (NH4)2SO4, in kilograms, to be supplied in a fermentation medium where the desired final cell concentration is 30 g 1 in a 10 I culture volume. Assume that the cells are...
-
Transactions during March 2023. Amounts include VAT of 15%, where applicable. 1 Received an electronic payment from V Majola, a debtor, for R13 500 (receipt no 41). Cash sales of steel products, R16...
-
For calendar 2 0 2 0 , Budapest Corp. reported net income of $ 2 9 , 2 8 0 and earnings per share of $ 2 . 4 6 . There were 1 2 , 0 0 0 common shares outstanding during 2 0 2 0 . On Dec 3 1 , 2 0 2...
-
Critically evaluate how the stage of corporate lifecycle can influence or limit the choices of finance and therefore, firms capital structure.
-
Compare the demand for water with the demand for wine. The demand for wine is likely OA. relatively more elastic because wine is a necessity. OB. relatively more inelastic because wine is a...
-
PC Contractors, Inc., was an excavating business in Kansas City, Missouri. Union Bank made loans to PC, subject to a perfected security interest in its equipment and other assets, including...
-
The following table gives the average patient waiting time in minutes for patients from a random sample of 16 physicians, classified by type of practice and type of physician a. Classify each factor...
-
Using the data given in Problem 2 in Chapter 5 (with SBP as the dependent variable) and the accompanying computer output, find the best regression model, using α = .05 and the...
-
a.-e. Repeat Problem 8, parts (a) through (e), but use orthogonal polynomials. f. Compare the results obtained here to those obtained in Problems 8 and 9. Problem 8 This problem uses the data...
-
In testing a claim about a population mean, a larger z test statistic always results in a larger P-value. Decide whether the statement makes sense (or is clearly true) or does not make sense (or is...
-
In testing the claim that the mean IQ score of statistics students is greater than 100, the alternative hypothesis is expressed as > 100. Decide whether the statement makes sense (or is clearly...
-
A handy mnemonic for interpreting the P-value in a hypothesis test is this: If the P (value) is low, then the null must go.
Study smarter with the SolutionInn App