Status Codes

Create a treemap for visualizing status code on two levels: the status category (100, 200, 300, 400, 500) and the status codes’ actual values (200, 301, 404, etc.)

source

status_codes

 status_codes (status_list, height=600, width=None, theme='none',
               title='Status Codes', export_to_html=None)

Create a treemap to visualize a list of status codes.

Type Default Details
status_list list, tuple, pandas.Series A collection of HTTP status codes
height int 600
width NoneType None
theme str none Name of theme to use for the chart. Available themes:
ggplot2, seaborn, simple_white, plotly, plotly_white, plotly_dark,
presentation, xgridoff, ygridoff, gridon, none
title str Status Codes
export_to_html NoneType None
Returns plotly.graph_objects.Figure

Visualize the distribution of a list of status codes

codes = pd.read_csv('data/status_codes.csv')
codes
status
0 200
1 200
2 200
3 200
4 200
... ...
414398 200
414399 200
414400 200
414401 200
414402 200

414403 rows × 1 columns

status_codes(codes['status'])

Change the theme with the theme parameter

status_codes(codes['status'], theme='seaborn')
status_codes(codes['status'], theme='plotly_dark')

Change the dimensions of the charts with width and height

status_codes(codes['status'], width=700, height=700)

Modify the title of the chart, and make use of various HTML tags <a>, <b>, <br>, <i>, <sub>, <sup>

website = 'MyWebsite.com'
title = f'Error Codes distribution <b>400</b> and <b>500</b><br>clickable: <i><a href="https://mywebsite.com">{website}</i> – April 3, 2023'

status_codes(
    codes.query('status >= 400')['status'],
    title=title,
    height=700,
    width=1300,
    theme='ggplot2')

Export the chart to an interactive, downloadable, emailable file with export_to_html

status_codes(
    codes['status'],
    title='Status Code - Exported to HTML',
    export_to_html='data/status_code_chart.html')