Quick Check 8.6 – Data 100, Summer 2020
(Spring 2019 Midterm 1) For the following question consider the following tables. The cities table contains one row per city and its population in thousands. The names table contains one row per state. The states table contains one row per state with its population in millions. Assume that cities contains only a small subset of US cities. There may be multiple cities in each state, but every city is in a state that appears in both names and states, and every state contains at least one city.
Fill in the blanks to create a table t that is the same as cities but with an additional column ab containing the abbreviation (e.g. CA) of the state in which each city is located. Hint: The str.extract method of a Series called on a regular expression with one group returns a DataFrame with one column labeled 0 containing the first substring matching the group. Assume there is exactly one comma in each city value. t = cities.copy(); x = _____.str.extract(r'_____')[0]; t['ab'] = list(names.set_index(_____).loc[x, _____]
What should be in the first blank? *
What should be in the second blank? *
What should be in the third blank? *
What should be in the fourth blank? *
Submit
This form was created inside of UC Berkeley. Report Abuse