Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 ActivityGenderStateAge
Unusual/unexplained ActivityFemaleGeorgia56
Unusual/unexplained ActivityMaleGeorgia59
Fraudulent PatternsFemaleMichigan85
Unknown Source of FundsMaleNew York60
Unknown Source of FundsFemaleNew York45
ACH FraudMaleNevada64
Fraudulent PatternsMaleMichigan69
Suspicious CallMaleCalifornia66
Suspicious CallFemalePennsylvania75
ACH FraudFemaleOhio68
ACH FraudMaleWashington48
Fraudulent PatternsMaleWashington48
Elder Financial ExploitationFemaleMississippi82
ACH FraudMaleCalifornia81
Fraudulent PatternsMaleOhio66
Elder Financial ExploitationFemaleIllinois84
Unusual/unexplained ActivityMaleNew York93
Fraudulent DocumentsFemaleCalifornia44
Fraudulent DocumentsMaleCalifornia73
Fraudulent PatternsFemaleIllinois91
Suspicious CallFemaleCalifornia62

Step by Step Solution

3.44 Rating (147 Votes )

There are 3 Steps involved in it

Step: 1

import numpy as np import pandas as pd import matplotlibpyplot as plt import seaborn ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managerial Accounting Decision Making and Performance Management

Authors: Ray Proctor

4th edition

273764489, 978-0273764489

More Books

Students also viewed these Programming questions

Question

=+d. What is the expected time for completing both tasks?

Answered: 1 week ago