Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete the function load_data below to load and organize the dataset that we will use in subsequent questions. You should return a pandas Datafile with
Complete the function load_data below to load and organize the dataset that we will use in subsequent questions. You should return a pandas Datafile with 5 columns titled "state", "visitation_2016", "visitation_2017", "visitation_2018", and "visitation_2019". The first column should contain a state and the subsequent columns the number of visitors in each corresponding year. The following instructions will help you do that correctly:
- First import the US_States_Visited_2017.xlsx, US_States_Visited_2018.xlsx and US_States_Visited_2019.xlsx datasets. The three datasets are located at the assets folder. You may start with read_excel() function in pandas and remove the top and bottom rows. In each file, some column should contain the state. Subsequent columns include the number of visitors in two different years. Note that some data is duplicated.
- After that, pick out the relevant columns. Note that you will need to multiply all the visitation numbers by 1,000. For example, in 2019, the recorded visitation for Alabama state was supposed to be 141,000 after multiplying 1,000. This must be applied for all 3 datasets.
- Finally, you should merge the 3 datasets together, and rename the merged dataset called merged_US_states_visitation. The merged dataset should retain only the census states called state, 2016 visitation data called visitation_2016, 2017 visitation data called visitation_2017, 2018 visitation data called visitation_2018and 2019 visitation data called visitation_2019. To avoid confusion, when we join the datasets, keep every states that ever has international visitation data. Finally, order the state names alphabetically.
Data looks like this:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started