Question: contains the years themselves in order, so the first elements in the population and the years arrays correspond). In [36]: population_amounts = bpd.read_csv (data/world_population_2022.csv).get(Population).values population_years

![the population and the years arrays correspond). In [36]: population_amounts = bpd.read_csv](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f32a0cbfcca_04466f32a0c4839b.jpg)



contains the years themselves in order, so the first elements in the population and the years arrays correspond). In [36]: population_amounts = bpd.read_csv ("data/world_population_2022.csv").get("Population").values population_years = np.arange (1950, 2022+1) print("Population column:", population_amounts) print("Years column:", population_years) Population column: [2557619597 2594942227 2636777090 2682060684 2730237675 2782111389 2835315327 2891368627 2948159570 3000742521 3043031253 3084053711 3140239653 3210037409 3281477826 3350773176 3421097064 3490825940 3562887008 3637819236 3713457589 3791172327 3867519813 3943132388 4017779234 4089387557 4159536915 4230430893 4301282222 4374940345 4445975606 4527418598 4610620221 4694937687 4777055423 4862317393 4949951891 5040273543 5131575729 5222662682 5315511894 5403253915 5490481497 5568231516 5650178207 5733211108 5815333785 5895837672 5975189305 6053955779 6132455985 6211328357 6290282107 6369186797 6448262425 6527056809 6607396274 6689442159 6773319540 6857160919 6939761510 7022084781 7105001721 7188528811 7271598780 7353476064 7435151387 7516769535 7597066210 7676686052 7756873419 7831718605 7905336896] Years column: [1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022] In [38] : population_df = bpd.DataFrame() .assign Population=population_amounts, Year-population_years population_df Out[38]: Population Year 0 2557619597 1950 1 2594942227 1951 2 2636777090 1952 3 2682060684 1953 4 2730237675 1954 68 7597066210 2018 69 7676686052 2019 70 7756873419 2020 71 7831718605 2021 72 7905336896 2022 73 rows x 2 columns In [45]: population_by_year = population_df.set_index( 'Year') population_by_year Out[45]: Population Year 1950 2557619597 1951 2594942227 1952 2636777090 1953 2682060684 1954 2730237675 2018 7597066210 2019 7676686052 2020 7756873419 2021 7831718605 2022 7905336896 73 rows x 1 columns You can get an array of row names using .index . For instance, the array of row names of the population_by_year DataFrame is: In [48] : population_by_year.index Out [48]: Int64Index([1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022], dtype='int64', name='Year') Question 4.5. Finally, let's revisit the population_by_year DataFrame from earlier in the lab. Compute the year when the world population first went above 7 billion. 118]: year_population_crossed_7_billion = year population_crossed 7 billion Index Error Traceback (most recent call last
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
