python
Dashboard
My Repos
Compilers
Python Online
Node JS Online
Golang Online
codepy
Login
My Repos
Sign Out
Online Python Interpreter
Stop
Run
pandas as pd import numpy as np import time import matplotlib.pyplot as plt df =pd.DataFrame() csv_file = ".csv" def read_csv_file(): df =pd.read_csv(csv_file) print(df) def data_analysis_menu(): df = pd.read_csv(csv_file) while True: clear() print('\n\nData Analysis MENU ') print('_'*100) print('1. Show Whole DataFrame\n') print('2. Show Columns\n') print('3. Show Top Rows\n') print('4. Row Bottom Rows\n') print('5. Show Specific Column\n') print('6. Add a New Record\n') print('7. Add a New Column\n') print('8. Delete a Column\n') print('9. Delete a Record\n') print('10. Update a Record\n') print('11. RPO Report \n') print('12. Scheme Type Report \n') print('13. Data Summery\n') print('14. Exit (Move to main menu)\n') ch = int(input('Enter your choice:')) if ch == 1: print(df) wait = input() if ch == 2: print(df.columns) wait = input() if ch == 3: n = int(input('Enter Total rows you want to show :')) print(df.head(n)) wait = input() if ch == 4: n = int(input('Enter Total rows you want to show :')) print(df.tail(n)) wait = input() if ch ==5 print(df.columns) col_name = input('Enter Column Name that You want to print : ') print(df[col_name]) wait = input() if ch==6: a = input('Enter service Name :') b = input('Enter New Rpo Name :') c = input(' Enter New Scheme Type :') d= int(input('Enter Total LastWeekCount :')) e = int(input('Enter LastMonthCount :')) f = int(input('Enter YearTillDate :')) g = input('Enter Date of Entry') data={'ServiceName':a,'RpoName':b,'SchemeType':c,'LastWeekCount':d,'LastM onthCount':e,'YearTillDate':f,'Date':g} df = df.append(data,ignore_index=True) print(df) wait=input() if ch==7: col_name = input('Enter new column name :') col_value = int(input('Enter default column value :')) df[col_name]=col_value print(df) print('\n\n\n Press any key to continue....') wait=input() if ch==8: col_name =input('Enter column Name to delete :') del df[col_name] print(df) print('\n\n\n Press any key to continue....') wait=input() if ch==9: index_no =int(input('Enter the Index Number that You want to delete :')) df = df.drop(df.index[index_no]) print(df) print('\n\n\n Press any key to continue....') wait = input() if ch==11: print(df.columns) print(df['RpoName'].unique()) rp= input('Enter Rpo Name ') g = df.groupby('RpoName') print('Rpo Name ', rp) print(g['YearTillDate'].sum()) print('\n\n\n Press any key to continue....') wait=input() if ch==12: df1=df.SchemeType.unique() print('Available Schemes :',df1) print('\n\n') schName =input('Enter Scheme Type :') df1=df[df.SchemeType==schName] print(df1) print('\n\n\n Press any key to continue....') wait = input() if ch==13: print(df.describe()) print("\n\n\nPress any key to continue....") wait=input() if ch == 14: break # name of function : graph # purpose : To generate a Graph menu def graph(): df = pd.read_csv(csv_file) while True: clear() print('\nGRAPH MENU ') print('_'*100) print('1. Whole Data LINE Graph\n') print('2. Whole Data Bar Graph\n') print('3. Whole Data Scatter Graph\n') print('4. Whole Data Pie Chart\n') print('5. Bar Graph By User Condition\n') print('6. Bar Graph Scheme Type\n') print('7. Exit (Move to main menu)\n') ch = int(input('Enter your choice:' )) if ch==1: g = df.groupby('RpoName') x = df['RpoName'].unique() y = g['YearTillDate'].sum() plt.xticks(rotation='vertical') plt.xlabel('Regional Offices') plt.ylabel('Total Passport served') plt.title('Passport served') plt.grid(True) plt.plot(x, y) plt.show() if ch==2: g = df.groupby('RpoName') x = df['RpoName'].unique() y = g['YearTillDate'].sum() plt.xticks(rotation='vertical') plt.xlabel('Regional Offices') plt.ylabel('Total Passport served') plt.title('Passport served') plt.bar(x, y) if ch==7: break # function name : export_menu # purpose : function to generate export menu def export_menu(): df = pd.read_csv(csv_file) while True: clear() print('\n\nEXPORT MENU ') print('_'*100) print() print('1. CSV File\n') print('2. Excel File\n') #print('3. MySQL Table\n') print('4. Exit (Move to main menu)') ch = int(input('Enter your Choice : ')) if ch==1: df.to_csv('c:/backup/newPassport.csv') print('\n\nCheck your new file "newPassport.csv" on C: Drive.....') wait = input() if ch == 2: df.to_excel('c:/backup/newPassport.xlsx') print('\n\nCheck your new file "newPassport.xlsx" on C: Drive.....') wait = input() if ch == 4: break def main_menu(): clear() introduction() while True: clear() print('MAIN MENU ') print('_'*100) print() print('1. Read CSV File\n') print('2. Data Analysis Menu\n') print('3. Graph Menu\n') print('4. Export Data\n') print('5. Exit\n') choice = int(input('Enter your choice :')) if choice==1: print('We need to add two number') read_csv_file() wait=input() if choice==2: print('We need to subtract two number') data_analysis_menu() wait=input() if choice==3: graph() wait=input() if choice==4: export_menu() wait=input() if choice==5: break clear() made_by() # call your main menu main_menu()
Share this code with others
Public
Clear
My Repos
Repo
Lang
Login
Register
Login
Create a free account. No Credit card info required.
I agree with the Codepy
Term of Service
Sign Up