Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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:

image text in transcribedimage text in transcribed
OVERSEAS* VISITORS TO U.S. STATES and TERRITORIES 2019-2018 2019 2019 VOLUME 2018 2018 2019 STATE/TERRITO MARKET/ISITATION MARKETVISITATION Rank VISITATION SHARE 000 CHANGE SHARE New York 26.04% 10,518 -2.7% 27.09% 10,804 Florida 23.79% 3,610 2.5% 23.51% 9.377 California 19.93% 3.050 -5.6% 21.39% 8,531 Hawaiian Islands 8. 16% 3.296 3.6% 7.98% 3.183 EPEnON 7.57% 3,058 -5.7% 3.13% 3,243 Guam 4.56% 1,842 14.0% 4.05% 1.615 Massachusetts 4.32% 1,745 -4.9% 4.60% 1,835 Texas 4.32% 1,745 -10.0% 4.86% 1,938 llinois 3.85% 1,555 -4.0% 4.06% 1,619 10 Arizona 2.96% 1,196 2.3% 2.93% 1.169 New Jersey 2.87% 1.159 4.5% 2.78% 1,109 12 Pennsylvania 2.61% 1,054 4.0% 2.54% 13 1.013 Washington 2.29% 925 16.0% 2.00% 798 14 Georgia 2. 15% 868 3.6% 2. 10% 838 15 Utah 1.83% 739 2.9% 1.80% 718 16 Virginia 1.31% 529 7.0% 1.24% 495 17 Colorado 1.26% 509 -7.5% 1.38% 550 18 Louisiana 1.24% 507 0.5% 1.25% 499 19 North Carolina 1. 12% 452 -17.3% 1.37% 546 19 Ohio 1. 11% 148 5.0% 1.06% 123 21 Michigan 1.06% 428 -13.5% 1.24% 495 22 Maryland 1.01% 408 31.2% 0.78% 311 23 Tennessee 0.92% 372 -4.8% 0.98% 39 24 Connecticut 0.80% 323 10.9% 0.73% 291 25 Jregon 0.80% 323 5.2% 0.77% 307 26 Minnesota 0. 71% 287 1.4% 0.71% 283 27 South Carolina 0.61% 246 6.3% 0.58% 231 28 Wyoming 0.61% 246 23.4% 0.50% 195 25 Wisconsin 0.58% 234 -3.8% 0.61% 243 30 Indiana 0.56% 226 11. 1% 0.51% 203 31 Missouri 0.42% 170 -21. 1% 0.54% 215 32 New Mexico D.38% 153 16.2% 0.33% 132 32 Maine 0.37% 149 3.8% 0.36% 144 34 Alabama D.35% 141 -9.4% 0.39% 156 35 Rhode Island 0.28% 113 -19.0% 0.35% 140 36 Alaska 0.27% 109 -19.6% 0.34% 136 37 low a D.26% 105 19. 7% D.22% 88 38 New Hampshire 0.26% 105 -32.5% 0.39% 156 39 Oklahoma D.25% 101 -2.6% 0.26% 104 40 Kentucky 0.24% 97 -9.9% 0.27% 108 Excludes Canada and Mexico. States with 100 or more respondents are reported Source: U.S. Department of Commerce, ITA, National Travel and Tourism Office, For more information please contact ntto@trade.youimport numpy as np import matplotlib. pyplot as plt import pandas as pd import datetime def load data() : return None loads data () . head (25)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Discrete Mathematics With Applications

Authors: Susanna S Epp

5th Edition

0357035283, 9780357035283

More Books

Students also viewed these Mathematics questions

Question

Briefly describe Bacons four Idols. How do the Idols apply today?

Answered: 1 week ago

Question

6. How can a message directly influence the interpreter?

Answered: 1 week ago