Home /
Expert Answers /
Computer Science /
we-will-now-determine-which-status-codes-appear-for-each-request-type-loop-over-the-elements-of-t-pa146
(Solved):
We will now determine which status codes appear for each request type. Loop over the elements of t ...
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.