Ip Project Source Code
Ip Project Source Code
import time
import sqlalchemy
df = pd.DataFrame()
csv_file = "C:/Users/rakesh/Desktop/IP_notes/12IP/Projects/BankChurners.csv"
def introduction():
msg = '''
A manager at the bank is disturbed with more and more customers leaving their credit card
services.
They would really appreciate if one could predict for them who is gonna get churned so they can
proactively go to the customer to provide them better services and turn customers' decisions in
I got this dataset from a website with the URL as https://leaps.analyttica.com/home. I have been
using this for a while to get datasets and accordingly work on them to produce fruitful results.
Now, this dataset consists of 10,000 customers mentioning their age, salary, marital_status,
credit card limit, credit card category, etc. There are nearly 18 features.
We have only 16.07 % of customers who have churned. Thus, it's a bit difficult to train our model
the project can be run on any machine support Python and Pandas. Besides pandas we also used
The whole project is divided into four major parts ie reading, analysis, visualization and export. all
these
for x in msg:
print(x, end='')
time.sleep(0.002)
def made_by():
msg = '''
Roll No : 1234
session : 2020-21
Thanks for evaluating my Project.
\n\n\n
'''
for x in msg:
print(x, end='')
time.sleep(0.002)
def read_csv_file():
df = pd.read_csv(csv_file)
print(df)
def clear():
for x in range(65):
print()
def data_analysis_menu():
df = pd.read_csv(csv_file)
while True:
clear()
print('\n\nD A T A A N A L Y S I S M E N U ')
print('_'*100,'\n')
if ch == 1:
print(df)
if ch == 2:
print(df.columns)
print(df.head(n))
if ch == 4:
print(df.tail(n))
if ch == 5:
print(df.columns)
print(df[col_name])
if ch == 6:
'Income_Category':h,'Card_Category':i,'Months_on_book':j,'Total_Relationship_count':k,
'Month_Inactive_12_month':l,'Contacts_count_12_mon':m,'Credit_Limit':n,
'Total_Revolving_Bal':o,'Avg_Open_To_Buy':p,'Total_Amt_chng_Q4_Q1':q,'Total_Trans_Amt':r,
'Total_Trans_Ct':s,'Total_Ct_Chng_Q4_Q1':t,'Average_Utilization_Ration':u
df = df.append(data, ignore_index=True)
print(df)
if ch == 7:
df[col_name] = col_value
print(df)
wait = input()
if ch == 8:
del df[col_name]
print(df)
wait = input()
if ch == 9:
index_no = int(
df = df.drop(df.index[index_no])
print(df)
wait = input()
if ch == 10:
print(df.columns)
print(df['Type'].unique())
g = df.groupby('Type')
wait = input()
if ch == 11:
df1 = df.Gender.unique()
print('\n\n')
print(df1)
wait = input()
if ch == 12:
print(df.describe())
wait = input()
if ch == 13:
break
def graph():
df = pd.read_csv(csv_file)
while True:
clear()
print('_'*100)
if ch == 1:
g = df.groupby('Gender')
x = df['Gender'].unique()
y = g['Gender'].count()
#plt.xticks(rotation='vertical')
plt.xlabel('Gender')
plt.grid(True)
plt.show()
if ch == 2:
g = df.groupby('Gender')
x = df['Gender'].unique()
y = g['Gender'].count()
#plt.xticks(rotation='vertical')
plt.xlabel('Gender')
plt.grid(True)
plt.show()
wait = input()
if ch == 3:
g = df.groupby('Gender')
x = df['Gender'].unique()
y = g['Gender'].count()
#plt.xticks(rotation='vertical')
plt.xlabel('Gender')
plt.grid(True)
plt.scatter(x, y)
plt.show()
wait = input()
if ch == 4:
g = df.groupby("Card_Category")
x = df['Card_Category'].unique()
y = g['Card_Category'].count()
plt.xticks(rotation='vertical')
plt.show()
if ch == 5:
g = df.groupby("Education_Level")
x = df['Education_Level'].unique()
y = g['Education_Level'].count()
plt.bar(x, y)
#plt.xticks(rotation='vertical')
plt.grid(True)
plt.xlabel('Education Level')
plt.show()
wait = input()
if ch == 6:
g = df.groupby("Income_Category")
x = df['Income_Category'].unique()
y = g['Income_Category'].count()
plt.grid(True)
plt.xlabel('Income Group')
plt.ylabel('Card Users')
plt.bar(x,y)
plt.show()
if ch == 7:
break
def export_menu():
df = pd.read_csv(csv_file)
while True:
clear()
print('_'*100)
print()
if ch == 1:
df.to_csv('c:/backup/bankchurner_backup.csv')
if ch == 2:
df.to_excel('c:/backup/bankchurner_backup.xlsx')
if ch == 3:
engine = sqlalchemy.create_engine(
'mysql+pymysql://root:@localhost:3306/davschool')
df.to_sql(name='bankchurner_backup', con=engine,
index=False, if_exists='replace')
if ch == 4:
break
def main_menu():
clear()
introduction()
while True:
clear()
print('_'*100)
print()
print('5. Exit\n')
if choice == 1:
read_csv_file()
wait = input(
if choice == 2:
data_analysis_menu()
if choice == 3:
graph()
wait = input('\n\n Press any key to continue....')
if choice == 4:
export_menu()
wait = input(
if choice == 5:
break
clear()
made_by()
main_menu()