Create a readable graph for my code. I'm trying to show a graph that compares elder financial
Question:
Create a readable graph for my code. I'm trying to show a graph that compares elder financial exploitation (listed under the suspicious activity column) to age. I believe I need to somehow group the ages into bins before displaying them in a graph, but I do not know how to do that. I have over 3,000 ages in my population. Below is just a small sample of it. Here is the code I am running, which works, but lists every individual age. Also, the legend appears right over the graph, so I cannot read it clearly. (Not that is it clear anyway) Can anyone assist me with a code that will group the ages into ranges, such has 1-20, 21-30, etc.. I have ages that go up to 100. Any help is much appreciated!
#Import Modules
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
#Round the age column
activity.round()
#Convert Age column to float
activity['Age'] = activity['Age'].astype(float)
Elder_Financial_Exploitation_df = activity[activity['Suspicious Activity'] == 'Elder Financial Exploitation']
age_group = Elder_Financial_Exploitation_df.groupby('Age').size().reset_index(name='Count')
sns.countplot(data=Elder_Financial_Exploitation_df, x= 'Suspicious Activity', hue='Age')
Data columns (total 9 columns):
# Column Non-Null Count Dtype
0 Suspicious Activity 3328 non-null object
1 Gender 3328 non-null object
2 Age 3328 non-null object
3 State 3328 non-null object
4 Age 3328 non-null float64
Suspicious Activity | Gender | State | Age |
Unusual/unexplained Activity | Female | Georgia | 56 |
Unusual/unexplained Activity | Male | Georgia | 59 |
Fraudulent Patterns | Female | Michigan | 85 |
Unknown Source of Funds | Male | New York | 60 |
Unknown Source of Funds | Female | New York | 45 |
ACH Fraud | Male | Nevada | 64 |
Fraudulent Patterns | Male | Michigan | 69 |
Suspicious Call | Male | California | 66 |
Suspicious Call | Female | Pennsylvania | 75 |
ACH Fraud | Female | Ohio | 68 |
ACH Fraud | Male | Washington | 48 |
Fraudulent Patterns | Male | Washington | 48 |
Elder Financial Exploitation | Female | Mississippi | 82 |
ACH Fraud | Male | California | 81 |
Fraudulent Patterns | Male | Ohio | 66 |
Elder Financial Exploitation | Female | Illinois | 84 |
Unusual/unexplained Activity | Male | New York | 93 |
Fraudulent Documents | Female | California | 44 |
Fraudulent Documents | Male | California | 73 |
Fraudulent Patterns | Female | Illinois | 91 |
Suspicious Call | Female | California | 62 |
Managerial Accounting Decision Making and Performance Management
ISBN: 978-0273764489
4th edition
Authors: Ray Proctor