Vessel Count Category

Now let's take a look at the variable vessel_count_total. As you can see, each port has an assigned number of vessels of each type. For this task, we want you to focus on only one specific type: "total".

In this task, you're asked to create a new categorical variable that would assign the total vessel count to a category based on how many vessels were counted per port. The categories should be named "low", "medium", and "high", corresponding to the total vessel count. You can name this variable vessel_count_category.

You can define the categories ("bins") based on quantilesarrow-up-right.

pandas.qcut() is pandas' quantile-based discretization function that takes in a column (pandas.Series), the number of quantiles, and the labels for each bin and returns a new column (pandas.Series) with the categorizations. You can use this to define the new column.

You can then see how the vessel count is distributed across all these ports by using the .value_counts() function.

Last updated