Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I Part F: Status Codes In this part of the project, we will analyze the status mdes returned by the server. Create a list that
I Part F: Status Codes In this part of the project, we will analyze the status mdes returned by the server. Create a list that containing one occurrence of each value that appears as a status code within the elements of the nasa RDD, sorted in ascending order. Use RDD methods to determine the contents of this list and also to perform the sorting. Store the resulting list in a variable named status_codes and then print this list. We will now determine which status codes appear for each request type. Loop over the elements of the req_types list created in Part E. For each request type, perform the tasks described below. Attempt to perform steps 1 -5 with a single statement by chaining together RDD methods. 1. Apply a filter to the nasa RDD keeping only elements of the current request type. 2. Extract the status codes for these records. 3. Determine the collection of distinct status codes appearing for this request type. 4. Sort the distinct codes in increasing order. 5. Collect the results into a list. 6. Print a message stating which status codes appear for this request. Your final output should be formatted as follows: Status codes for GET requests: LIST_OF_STATUS_CODES Status codes for HEAD requests: LIST_OF_STATUS_CODES Status codes for POST requests: LIST_OF_STATUS_CODES Next, we will count the number of requests resulting in each status code. Perform the following steps in a single code cell. 1. Create an empty list named code_counts. 2. Loop over the elements of the status_codes list. For each status code, determine the number of requests resulting in that particular status code. Append the resulting count into the code_counts list. 3. Use the contents of status_codes and code_counts to create a bar chart displaying the number of requests resulting in each status code. Construct your bar chart according to the following specifications: a. The figure size should be [10, 4]. b. Select a single named color to use for the bars. Add a black border to each bar. C. The chart should be titled "Distribution of Status Codes" d. The x-axis should be labeled "Status Code" and the y-axis should be labeled "Count". e. The heights of the bars will be on dramatically different scales. For this reason, we will use a log scale for the y-axis. This can be set using plt . yscale( 'log'). f. Use plt. show() to display the figure
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