# Crime Types

Let’s dive deeper and look into the different crime types. What do you think are the most common crime types? To answer this question, we want to plot the ten most common crime types in descending order.

* [ ] How many different crime types are in this data set?
* [ ] Plot the ten most common crime types in descending order.

We reduced the different crime types by dividing them into superordinate groups in order to get a better overview, but you don't have to do this. The result looks like this:

<figure><img src="/files/2bPfebKvPxBk1ettUkP0" alt="" width="563"><figcaption></figcaption></figure>

With these 10 most common crime types, let's look at the gender distribution for these crime types.

* [ ] Plot the percentage of men and women affected by the 10 most common crime types.

  <figure><img src="/files/xzzZl7Ea1bqG7Rk20hk1" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}
Your plots don't have to look exactly like this. Actually, we encourage you to realize your own ideas. Most of the times you will find a solution to your problem by using a search engine of your choice or websites like stackoverflow\.com.
{% endhint %}

{% hint style="info" %}
:pirate\_flag:: `geom_col()` or `geom_bar()` will make a stacked barplot by default. But sometimes, you may want to have the bars side by side for ease of comparability. This is done by the `position` argument.
{% endhint %}

{% hint style="info" %}
&#x20;:snake:: When analyzing the frequency of categories, use `nunique()` to count the distinct types in a column, or `value_counts()` to rank them by occurrence. To visualize the top categories, use `plot(kind='barh')` for a horizontal bar chart, which works well for long category names. For grouped data, `groupby()` combined with `size()` can calculate category counts for each group, and `unstack()` pivots the data for better visualization. When customizing plots, specify colors explicitly with a dictionary (e.g., for gender categories), and ensure that less common categories are represented distinctly. Experiment with `grid()` and `title()` to improve readability and aesthetics!
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://techacademy.gitbook.io/data-science-wintersemester-24-25/exploratory-data-analysis-eda/data-visualization/crime-types.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
