Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A basic comparison graph in Python between one data point within one column to another column and I am not sure where to start. Specifically,

A basic comparison graph in Python between one data point within one column to another column and I am not sure where to start. Specifically, I would like to compare elder financial exploitation within the suspicious activity column to gender, then repeat with that same activity and compare it to the state then age (So 4 graphs all together). I am sure I can figure out how to repeat the coding, but need help getting it started.


Below is a snapshot of some of the data I am playing around with, as well as some of my code. Any help is greatly appreciated!

#Import Modules

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib import gridspec

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

#Group the data by "Suspicious Activity" and "Gender" and count the number of occurrences

gender_group = df.groupby(["Suspicious Activity", "Gender"]).size().reset_index(name="Count")

sns.barplot(x="Elder Financial Exploitation", y="Count", hue="Gender", data=gender_group) plt.show()

Step by Step Solution

3.33 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

To create a basic comparison graph between Elder Financial Exploitation and other columns such as Ge... 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

Foundations of Financial Management

Authors: Stanley Block, Geoffrey Hirt, Bartley Danielsen, Doug Short, Michael Perretta

10th Canadian edition

1259261018, 1259261015, 978-1259024979

More Books

Students also viewed these Programming questions

Question

How might FLSA standards apply to Joes compensation decisions? LO.1

Answered: 1 week ago