Performing categorical variable analysis

Categorical variable analysis helps us understand the categorical types of data. Categorical types are non-numeric. In this recipe, we're using days of the week. Technically, it's a category as opposed to purely numeric data. The creators of the dataset have already converted the category—the name of the day of the week—to a number. If they had not done this, we could use Pandas to do it for us, and then perform our analysis.

In this recipe, we are going to plot the distribution of casualties by the day of the week.

How to do it…

  1. First, import the Python libraries that you need:
    import pandas as pd
    import numpy as np
    import matplotlib as plt
    import matplotlib.pyplot as plt
    %matplotlib inline
  2. Next, define a variable ...

Get Python Business Intelligence Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.