Question: I used Python as my programing language. Can you please tell me why my Problem 4 and 5 isn't working? If possible can you write
I used Python as my programing language. Can you please tell me why my Problem 4 and 5 isn't working?
If possible can you write the correct code?


Problem 4 Create a DataFrame caled mlax by importing the men's lacrosse tean roster from "httpa: iliund. com'sports'mlaxiroster". After previeving ti ax, you notice that the freshmen have no height, weight, home town and high school data. Remove the freshmen from the roster. Display the first 10 rows of mlax. Hint Go to the webpage to identify the HTML tables on the page and what kind of data is stored in them. B]: KeyErrot Traceback (nost recent ca11 last) in cinodula 1mlax = pd.read_htm1("https://und. con/sports/mlax/roster/* [ [a] 2 rows =mlax[ "Class"] != "Freshnat" 3m lax [rous] [cols] 4mlax. head (10) /usr/1sb/python3.7/site-packages/pandas/core/frane.py in petitent_ (selt, key) /usr/1ib/python 3.7/site-packages/pandas/core/indexing-py in get__1stlike_lidexer(self, key, axis) 1312 keyarr, indexer, new_indexer = ax__reindex_non_unique(keyarr) 1313 1314 1315 1316 If needs_18_conversion(ax.dtype) or isinstance( 1375 1376 not_found = list(ensure_index(key) [missing_mask.nonzero()[e]].unique()) KeyError: "None of [Index(['make', 'node1", 'year', "cylinder's", 'class', "transnissiontype'], dtype='object')] are In the [col unns] " Problem 5 Write code that continually prompts a user for a two-letter state code, assigns the input to a variable called haine_state and proceeds as follows: 1. If the input is a valid state code (i.e. exists in states) and there are players from the state in mlax, create a DataFrame called players with just those players and display it. 2. If the input is a valid state code and there are no players from the state in mlax, print a message that reads "There are nio player's fron "\{hone_state\}" ." 3. If the input is not a valid state code, print a message that reads "Invalld state code! Please try again. ". 4. If the input is "exit", stop the code. Hint: My solution looks something like this: while True: home_state = input("Enter a two-letter state code: ") if break= else: else: prlnt( "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "MV", "MA", "NJ", "SO", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"] while True: hone_state = input('Enter a two-letter' state code: ') hone_state.upper () if hone_state = "exil: : break else: 1f home_state in states: rows = mlax['Honetown' ].str. endswith(tione_state) players = nlax[rows] if len(players)=: print("There are no players from \{\}+, fornat(hone_state) ) else: display(players) else: print("Invalid state code! Please try again. ") Problem 4 Create a DataFrame caled mlax by importing the men's lacrosse tean roster from "httpa: iliund. com'sports'mlaxiroster". After previeving ti ax, you notice that the freshmen have no height, weight, home town and high school data. Remove the freshmen from the roster. Display the first 10 rows of mlax. Hint Go to the webpage to identify the HTML tables on the page and what kind of data is stored in them. B]: KeyErrot Traceback (nost recent ca11 last) in cinodula 1mlax = pd.read_htm1("https://und. con/sports/mlax/roster/* [ [a] 2 rows =mlax[ "Class"] != "Freshnat" 3m lax [rous] [cols] 4mlax. head (10) /usr/1sb/python3.7/site-packages/pandas/core/frane.py in petitent_ (selt, key) /usr/1ib/python 3.7/site-packages/pandas/core/indexing-py in get__1stlike_lidexer(self, key, axis) 1312 keyarr, indexer, new_indexer = ax__reindex_non_unique(keyarr) 1313 1314 1315 1316 If needs_18_conversion(ax.dtype) or isinstance( 1375 1376 not_found = list(ensure_index(key) [missing_mask.nonzero()[e]].unique()) KeyError: "None of [Index(['make', 'node1", 'year', "cylinder's", 'class', "transnissiontype'], dtype='object')] are In the [col unns] " Problem 5 Write code that continually prompts a user for a two-letter state code, assigns the input to a variable called haine_state and proceeds as follows: 1. If the input is a valid state code (i.e. exists in states) and there are players from the state in mlax, create a DataFrame called players with just those players and display it. 2. If the input is a valid state code and there are no players from the state in mlax, print a message that reads "There are nio player's fron "\{hone_state\}" ." 3. If the input is not a valid state code, print a message that reads "Invalld state code! Please try again. ". 4. If the input is "exit", stop the code. Hint: My solution looks something like this: while True: home_state = input("Enter a two-letter state code: ") if break= else: else: prlnt( "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "MV", "MA", "NJ", "SO", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"] while True: hone_state = input('Enter a two-letter' state code: ') hone_state.upper () if hone_state = "exil: : break else: 1f home_state in states: rows = mlax['Honetown' ].str. endswith(tione_state) players = nlax[rows] if len(players)=: print("There are no players from \{\}+, fornat(hone_state) ) else: display(players) else: print("Invalid state code! Please try again. ")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
