New Code After Edit
New Code After Edit
import numpy as np
import matplotlib.pyplot as plt
print('Credit Card Analysis for year 2021 and 2022')
print('Choose the year')
print('1. 2021')
print('2. 2022')
choice = int(input('Enter your choice'))
if(choice == 1):
print('\n Showing Data for 2021')
print('Choose the data')
print('1. Age wise analysis ')
print('2. Gender wise analysis')
print('3. Education level based analysis')
print('4. Income category based analysis')
print('5. Card wise analysis')
for a in range(5):
option=int(input('Enter your choice'))
print('')
if option==1:
print('Showing Data Analysis Based on Age:\n')
Transaction_Amount=(1144,1291,1887,1171,816,1088,1330,1538,1350,
1201,1314,1539,1311,1265)
plt.title("Age vs Transaction Amount Graph")
plt.barh(Age,Transaction_Amount,color=['red','yellow','green',
'blue','orange','violet',
'white','cyan','pink',
'darkgreen','darkblue',
'olive','yellowgreen',
'darkolivegreen','lawngreen'])
14
plt.xlabel("Age")
plt.ylabel("Transaction_Amount")
plt.grid(True)
plt.show( )
if option == 2:
print('Showing Data Analysis Based on Gender')
df=pd.read_csv("C:/Users/Hp/Pictures/2021Gender analysis.csv")
print(df)
print('')
print('Graph')
Gender=['Male','Female']
no_of_users=[8,7]
plt.title("Male vs Female Credit Card Users")
plt.bar(Gender,no_of_users,color=['violet','darkblue'])
plt.xlabel("Gender")
plt.ylabel("No of Users")
plt.show()
if option == 3:
print('Showing Education Level Based Data')
df=pd.read_csv("C:/Users/Hp/Pictures/2021edulvl.csv")
print(df)
print('')
print('Graph')
education_level=['College','Graduate','PostGraduate','High School','Doctorate']
number=[1,5,3,3,3]
plt.title('Education Level')
plt.bar(education_level,number,color=['red','yellow','blue','green','pink'])
plt.xlabel('Education level')
plt.ylabel('No of Users')
plt.show()
if option == 4:
print('Showing Data Based on Income Category')
15
df=pd.read_csv("C:/Users/Hp/Pictures/2021incmcategory.csv")
print(df)
print('')
print('Graph')
income_category=['$40k-$60k','$60k-$80k','$60k-$120k']
number=[5,6,4]
plt.title('Income Based Credit Card Users')
plt.bar(income_category,number,color=['gold','silver','red'])
plt.xlabel('Income category')
plt.ylabel('No of Users')
plt.show( )
if option == 5:
print('Showing data based on type of card users')
df=pd.read_csv("C:/Users/Hp/Pictures/2021cardbased.csv")
print(df)
print('')
print('Graph')
card_category=['blue','gold','silver']
number=[9,3,3]
plt.title('Card Based Credit Card Users')
plt.bar(card_category,number,color=['blue','gold','silver'])
plt.xlabel('Type of Card')
plt.ylabel('No of Users')
plt.show( )
if (choice == 2 ):
print('\n Showing Data for 2021')
print('Choose the data:')
print('1. Age wise analysis ')
print('2. Gender wise analysis')
print('3. Education level based analysis')
print('4. Income category based analysis')
print('5. Card wise analysis')
for a in range(5):
option=int(input('Enter your choice'))
print('')
16
if option==1:
print('Showing Data Analysis Based on Age:\n')
df=pd.read_csv("C:/Users/Hp/Pictures/2022 Age anaylsis.csv")
print(df)
print('')
print("Graph")
Age=[35,57,44,48,41,61,45,62,41,47,54,41,59,63]
Transaction_Amount=(1570,1348,1671,1028,1336,1207,1178,692,
931,1126,1110,1051,1197,1904,1265)
plt.title("Age vs Transaction Amount Graph")
plt.barh(Age,Transaction_Amount,color=['red','yellow','green',
'blue','orange','violet',
'white','cyan','pink','darkgreen',
'darkblue','olive','yellowgreen',
'darkolivegreen','lawngreen'])
plt.xlabel("Age")
plt.ylabel("Transaction_Amount")
plt.grid(True)
plt.show()
if option == 2:
print('Showing Data Analysis Based on Gender')
df=pd.read_csv("C:/Users/Hp/Pictures/2022Gender analysis.csv")
print(df)
print('')
print('Graph')
Gender=['Male','Female']
no_of_users=[10,5]
plt.title("Male vs Female Credit Card Users")
plt.bar(Gender,no_of_users,color=['violet','darkblue'])
plt.xlabel("Gender")
plt.ylabel("No of Users")
plt.show()
if option == 3:
print('Showing Education Level Based Data')
df=pd.read_csv("C:/Users/Hp/Pictures/2022education based.csv")
print(df)
17
print('')
print('Graph')
education_level=['College','Graduate','PostGraduate','High School','Doctorate']
number=[3,5,1,4,2]
plt.title('Eduction Level')
plt.bar(education_level,number,color=['red','yellow','blue','green','pink',])
plt.xlabel('Education level')
plt.ylabel('No of Users')
plt.show()
if option == 4:
print('Showing Data Based on Income Category')
df=pd.read_csv("C:/Users/Hp/Pictures/2022incmbased.csv")
print(df)
print('')
print('Graph')
income_category=['$40k-$60k','$60k-$80k','$60k-$120k']
number=[5,4,6]
plt.title('Income Based Credit Card Users')
plt.bar(income_category,number,color=['gold','silver','red'])
plt.xlabel('Income category')
plt.ylabel('No of Users')
plt.show()
if option == 5:
print('Showing data based on type of card users')
df=pd.read_csv("C:/Users/Hp/Pictures/2022cardbased.csv")
print(df)
print('')
print('Graph')
card_category['blue','gold','silver']
number=[8,3,4]
plt.title('Card Based Credit Card Users')
18
plt.bar(card_category,number,color=['blue','gold','silver'])
plt.xlabel('Type of Card')
plt.ylabel('No of Users')
plt.show()
19