A basic comparison graph in Python between one data point within one column to another column and
Question:
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 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 |
#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()
Foundations of Financial Management
ISBN: 978-1259024979
10th Canadian edition
Authors: Stanley Block, Geoffrey Hirt, Bartley Danielsen, Doug Short, Michael Perretta