https://colab.research.google.com/gist/sumitkhanna2222/863f8612355191008204cc211d209cbb
-
-
Save jjackofall/863f8612355191008204cc211d209cbb to your computer and use it in GitHub Desktop.
863f8612355191008204cc211d209cbb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.ipynb_checkpoints/MaMo_v1-checkpoint.ipynb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# MaMo\n", | |
"## Manage money\n", | |
"\n", | |
"### Overview\n", | |
"* Wallet ( All , Bank, Paytm, etc ).\n", | |
"* View ( All, Date , week, month , year, Weekends ).\n", | |
"* Options ( +, - , <> Transfer).\n", | |
"* Income ( All, Deposit, Salary, Savings,Funds, etc).\n", | |
"* Expenses( All, Food, transport , Shopping, Entertainment, Health, personal, etc).\n", | |
"* Tags (for easy access, customisable as per user requirements.\n", | |
"\n", | |
"### Features\n", | |
"* Graphical representation ( Pie chart, histogram, etc).\n", | |
"* Currency.\n", | |
"* Subscriptions ( netflix , YouTube etc).\n", | |
"* Reccurring ( Salary, Transportation, milk, etc) -- can be modified as per changes in cycle.\n", | |
"* Define first weekday & weekends.\n", | |
"* Reminder expenses through mail (Insurance, pollution check , fees ).\n", | |
"* Sort ( Greater than amount, Date, month , all , hashtags , categories , expenses , incomes , etc).\n", | |
"* Loan.\n", | |
"* Calculator (for easy calculation).\n", | |
"* Daily reminder to enter the expenditure of today.\n", | |
"* Reminder when money is low through mail.(user can set min amount when the reminder should be triggered).\n", | |
"* Borrow ( +,-).\n", | |
"* Reminder about lending money to friends family etc.(after a week, month or so).\n", | |
"* Export to excel, csv etc.\n", | |
"* Speech recognition system.\n", | |
"\n", | |
"### Future possibility\n", | |
"* If the lender and borrower are users of the app/website then both will get reminder.\n", | |
" * Lender - you gave money to xyz person on (date). Feature of adding interest after crossing the time limit of returning money.\n", | |
" * Borrower - you borrowed money from pqr on (date). Return today to avoid interest.\n", | |
"* Tips section - to save money, increase money, easy money, dos and donts etc.\n", | |
"* Offers and coupon codes.\n", | |
"* share feature on other platforms" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"'''------- importing required libraries and packages ---------'''\n", | |
"import pandas as pd #importing pandas" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# transaction_id, type, wallets, amount, category, entry_date, transaction_date, current_date, tags, comments, flag \n", | |
"# reccuring, subscriptions, loan, reminder, borrow, " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 51, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Total Balance = 0\n", | |
"Total Income = 0\n", | |
"Total Expenditure = 0\n", | |
"1) Income\n", | |
"2) Expenditure\n", | |
"3) View Transactions\n", | |
"Please select option(1-3):1\n", | |
"Enter the Amount:232\n", | |
"Tag:#efef\n", | |
"Comments:ferfed\n", | |
"Total Balance = 232\n", | |
"Total Income = 232\n", | |
"Total Expenditure = 0\n" | |
] | |
} | |
], | |
"source": [ | |
"t = pd.Timestamp.now().replace(microsecond=0)\n", | |
"\n", | |
"'''------- Creating raw DataFrames ---------'''\n", | |
"df = pd.DataFrame({'transaction_id':[0,1],'type':['Income','Expenditure'], 'wallets':['Cash','Cash'], 'amount':[0, 0], 'category':['Food','Travel'], 'entry_date':[t,t], 'transcation_date':[t,t], 'current_date':[t,t], 'tags':['',''], 'comments':['',''], 'flag':[1,1] }) #creating sample dataframe (df) having two columns\n", | |
"df_cat = pd.DataFrame({'Category':['Food','Travel',], 'entry_date':[t,t], 'current_date':[t,t], 'flag':[1,1]})\n", | |
"\n", | |
"writer = pd.ExcelWriter('MaMo.xlsx', engine='xlsxwriter')\n", | |
"df.to_excel(writer, sheet_name=\"Transactions\", index=False) #inserting data of dataframe df (df) in the excel sheet\n", | |
"df_cat.to_excel(writer, sheet_name=\"Category\", index=False) #inserting category list in the excel sheet\n", | |
"writer.save() #Close the Pandas Excel writer and output the Excel file.\n", | |
"\n", | |
"ndf = pd.read_excel('MaMo.xlsx', sheet_name=\"Transactions\",sort=False) #creating new dataframe (ndf) to open the file in read mode\n", | |
"ndf_cat = pd.read_excel('MaMo.xlsx', sheet_name=\"Category\",sort=False) #creating new dataframe (ndf) to open the file in read mode\n", | |
"\n", | |
"writer = pd.ExcelWriter('MaMo.xlsx', engine='xlsxwriter')\n", | |
"'''------- defining functions -------'''\n", | |
"\n", | |
"def home(): #defining home function\n", | |
" #creating required dataframes\n", | |
" income_df = ndf.loc[ndf['type'] == 'Income'] # creating income dataframe (income_df) to store the entries having income type\n", | |
" expenditure_df = ndf.loc[ndf['type'] == 'Expenditure'] # creating income dataframe (expenditure_df) to store the entries having expenditure type\n", | |
" \n", | |
" #calculating Total of the required values\n", | |
" income_amount = income_df['amount']\n", | |
" income_total = income_amount.sum(axis = None, skipna = True) #total income\n", | |
" \n", | |
" expenditure_amount = expenditure_df['amount']\n", | |
" expenditure_total = expenditure_amount.sum(axis = None, skipna = True) #total expenditure\n", | |
" \n", | |
" avail_balance_total = income_total - expenditure_total # total available balance\n", | |
" \n", | |
" #printing required data\n", | |
" print(\"Total Balance = \",avail_balance_total,sep='') #displays total balance\n", | |
" print(\"Total Income = \",income_total,sep='') #displays total income\n", | |
" print(\"Total Expenditure = \",expenditure_total,sep='') #displays total expenditure\n", | |
" \n", | |
"''' ------- function defintion end ------'''\n", | |
"\n", | |
"home() #calling home function to display data of user on startup\n", | |
"\n", | |
"#providing options for user to choose from\n", | |
"#print('Choose from list of wallets:')\n", | |
"#print(rdf_wallet)\n", | |
"t_id = len(ndf) # generating unique transaction ids\n", | |
"\n", | |
"print(\"1) Income\")\n", | |
"print(\"2) Expenditure\")\n", | |
"print(\"3) View Transactions\")\n", | |
"option = int(input(\"Please select option(1-3):\")) #storing option value selected by user\n", | |
"\n", | |
"#performing functions on the basis of option selected by user\n", | |
"\n", | |
"if option == 1: #insert income amount\n", | |
" amount = int(input('Enter the Amount:')) # taking amount input from user\n", | |
" print(\"Category:\")\n", | |
" cat_lst = ndf_cat['Category'].values\n", | |
" count2 = 1\n", | |
" print(\"0) Add new category.\")\n", | |
" for i in cat_lst:\n", | |
" print(\"{}) {}\".format(count2,i))\n", | |
" count2 += 1\n", | |
" option1_0 = int(input(\"Please select category(0-{}): \".format(count2-1))) #storing option1_0 value selected by user\n", | |
" if option1_0 == 0:\n", | |
" category = input(\"Enter the New Category you wish to add:\")\n", | |
" tdf2 = pd.DataFrame({'Category':[category],'entry_date':[t], 'current_date':[t], 'flag':[1]}) #creating temporary dataframe (tdf2)\n", | |
" ndf_cat = ndf_cat.append(tdf2, ignore_index=True,sort=False) #append the new input in the dataframe (ndf)\n", | |
" \n", | |
" elif option1_0 < count2 and option1_0 > 0:\n", | |
" category = cat_lst[option1_0 - 1]\n", | |
" else:\n", | |
" print('Wrong Input!!') #error message\n", | |
" \n", | |
" tag = input(\"Tag:#\") # hashtags \n", | |
" comment = input(\"Comments:\") # additional comments\n", | |
" tdf = pd.DataFrame({'type':['Income'], 'amount': [amount],'tags':[tag],'comments':[comment],'transaction_id':[t_id],'wallets':['Cash'], 'category':[category], 'entry_date':[t], 'transcation_date':[t], 'current_date':[t], 'flag':[1]}) #creating temporary dataframe (tdf)\n", | |
" ndf = ndf.append(tdf, ignore_index=True,sort=False) #append the new input in the dataframe (ndf)\n", | |
" ndf.to_excel(writer, sheet_name='Transactions', index=False) #updating the excel sheet\n", | |
" ndf_cat.to_excel(writer, sheet_name='Category', index=False) #updating the excel sheet\n", | |
" writer.save() #Close the Pandas Excel writer and output the Excel file.\n", | |
" home() #display data to user\n", | |
" \n", | |
"elif option == 2: #insert expenditure amount\n", | |
" amount = int(input('Enter the Amount:')) # taking amount input from user\n", | |
" tdf = pd.DataFrame({'type':['Expenditure'], 'amount': amount}) #creating temporary dataframe (tdf)\n", | |
" ndf = ndf.append(tdf, ignore_index=True,sort=False) #append the new input in the dataframe (ndf)\n", | |
" ndf.to_excel(writer, sheet_name='Transactions', index=False) #updating the excel sheet\n", | |
" writer.save()\n", | |
" home() #display data to user\n", | |
" \n", | |
"elif option == 3: # view transactions\n", | |
" # Date , week, month , year, Weekends\n", | |
" print(\"1) All\")\n", | |
" print(\"2) Date\")\n", | |
" print(\"3) Week\")\n", | |
" print(\"4) Month\")\n", | |
" print(\"5) Year\")\n", | |
" print(\"6) Weekends\")\n", | |
" print(\"7) Category\")\n", | |
" print(\"8) Tags\")\n", | |
" print(\"9) Wallets\")\n", | |
" print(\"10) Type\")\n", | |
" option3 = int(input(\"Please select option(1-10):\")) #storing option3 value selected by user\n", | |
" \n", | |
" #performing functions on the basis of option selected by user\n", | |
" \n", | |
" if option3 == 1: # Display all data\n", | |
" print(ndf[['type','wallets','amount','category','transcation_date','tags','comments']]) # displaying stored data of the user\n", | |
" \n", | |
" elif option3 == 2: # Display data Date wise\n", | |
" print(\"1) Today\")\n", | |
" print(\"2) Date\")\n", | |
" print(\"3) From-To\")\n", | |
" option3_2 = int(input(\"Please select option(1-3): \")) #storing option3_2 value selected by user\n", | |
" \n", | |
" if option3_2 == 1: \n", | |
" t_ndf = ndf[(ndf['transcation_date'].dt.date == t.date())] # assigning data of today\n", | |
" print(t_ndf[['type','wallets','amount','category','transcation_date','tags','comments']]) # displaying todays data of the user\n", | |
" \n", | |
" elif option3_2 == 2:\n", | |
" e_dt = pd.to_datetime(input(\"Please the enter the date(yyyy-mm-dd): \")).date()\n", | |
" t_ndf = ndf[(ndf['transcation_date'].dt.date == e_dt)] # assigning data of date enterd\n", | |
" \n", | |
" if t_ndf.empty :\n", | |
" print(\"NO DATA FOUND!!!\")\n", | |
" else:\n", | |
" print(t_ndf[['type','wallets','amount','category','transcation_date','tags','comments']]) # displaying todays data of the user\n", | |
" \n", | |
" elif option3_2 == 3:\n", | |
" f_dt = pd.to_datetime(input(\"Please the enter the from date(yyyy-mm-dd): \")).date()\n", | |
" t_dt = pd.to_datetime(input(\"Please the enter the to date(yyyy-mm-dd): \")).date()\n", | |
" t_ndf = ndf[(ndf['transcation_date'].dt.date >= f_dt) & (ndf['transcation_date'].dt.date <= t_dt)]\n", | |
" \n", | |
" if t_ndf.empty :\n", | |
" print(\"NO DATA FOUND!!!\")\n", | |
" else:\n", | |
" print(t_ndf[['type','wallets','amount','category','transcation_date','tags','comments']]) # displaying todays data of the user\n", | |
" else: \n", | |
" print('Wrong Input!!') #error message \n", | |
" \n", | |
" elif option3 == 3: # Display data week wise\n", | |
" print(\"1) Current week\")\n", | |
" print(\"2) Particular week\")\n", | |
" option3_3 = int(input(\"Please select option(1-2): \")) #storing option3_10 value selected by user\n", | |
" \n", | |
" if option3_3 == 1:\n", | |
" pass\n", | |
" elif option3_3 == 2:\n", | |
" pass\n", | |
" else :\n", | |
" print('Wrong Input!!') #error message\n", | |
" \n", | |
" elif option3 == 4: # Display data month wise\n", | |
" print(\"1) Current month\")\n", | |
" print(\"2) Particular month\")\n", | |
" option3_4 = int(input(\"Please select option(1-2): \")) #storing option3_10 value selected by user\n", | |
" \n", | |
" if option3_4 == 1:\n", | |
" m_ndf = ndf[(ndf['transcation_date'].dt.month == t.date().month)] # assigning data of today\n", | |
" print(m_ndf[['type','wallets','amount','category','transcation_date','tags','comments']]) # displaying todays data of the user\n", | |
" \n", | |
" elif option3_4 == 2:\n", | |
" yer = int(input(\"Enter the Year(YYYY)\"))\n", | |
" y_ndf = ndf[(ndf['transcation_date'].dt.year == yer)] # assigning data of today\n", | |
" mon = int(input(\"Enter the Year(mm)\"))\n", | |
" m_ndf = y_ndf[(y_ndf['transcation_date'].dt.month == mon) & ((y_ndf['transcation_date'].dt.year == yer))] # assigning data of today\n", | |
" \n", | |
" if m_ndf.empty :\n", | |
" print(\"NO DATA FOUND!!!\")\n", | |
" else:\n", | |
" print(m_ndf[['type','wallets','amount','category','transcation_date','tags','comments']]) # displaying todays data of the user\n", | |
" else :\n", | |
" print('Wrong Input!!') #error message\n", | |
" \n", | |
" elif option3 == 5: # Display data year wise\n", | |
" print(\"1) Current year\")\n", | |
" print(\"2) Particular year\")\n", | |
" option3_5 = int(input(\"Please select option(1-2): \")) #storing option3_10 value selected by user\n", | |
" \n", | |
" if option3_5 == 1:\n", | |
" y_ndf = ndf[(ndf['transcation_date'].dt.year == t.date().year)] # assigning data of today\n", | |
" print(y_ndf[['type','wallets','amount','category','transcation_date','tags','comments']]) # displaying todays data of the user\n", | |
" \n", | |
" elif option3_5 == 2:\n", | |
" yer = int(input(\"Enter the Year(YYYY)\"))\n", | |
" y_ndf = ndf[(ndf['transcation_date'].dt.year == yer)] # assigning data of today\n", | |
" \n", | |
" if y_ndf.empty :\n", | |
" print(\"NO DATA FOUND!!!\")\n", | |
" else:\n", | |
" print(y_ndf[['type','wallets','amount','category','transcation_date','tags','comments']]) # displaying todays data of the user\n", | |
" else :\n", | |
" print('Wrong Input!!') #error message\n", | |
" \n", | |
" elif option3 == 6: # Display data weekend wise\n", | |
" print(\"1) Last weekend\")\n", | |
" print(\"2) Particular weekend\")\n", | |
" option3_6 = int(input(\"Please select option(1-2): \")) #storing option3_10 value selected by user\n", | |
" \n", | |
" if option3_6 == 1:\n", | |
" pass\n", | |
" elif option3_6 == 2:\n", | |
" pass\n", | |
" else :\n", | |
" print('Wrong Input!!') #error message\n", | |
" \n", | |
" elif option3 == 7: # Display data category wise\n", | |
" cat_lst = ndf['category'].unique()\n", | |
" count = 1\n", | |
" for i in cat_lst:\n", | |
" print(\"{}) {}\".format(count,i))\n", | |
" count += 1\n", | |
" option3_7 = int(input(\"Please select option(1-{}): \".format(count-1))) #storing option3_10 value selected by user\n", | |
" if option3_7 < count and option3_7 > 0:\n", | |
" cat_ndf = ndf[(ndf['category'] == cat_lst[option3_7 - 1])]\n", | |
" print(cat_ndf[['type','wallets','amount','category','transcation_date','tags','comments']]) # displaying todays data of the user\n", | |
" else:\n", | |
" print('Wrong Input!!') #error message\n", | |
" \n", | |
" elif option3 == 8: # Display data tags wise \n", | |
" pass\n", | |
" elif option3 == 9: # Display data acc to wallet wise\n", | |
" pass\n", | |
" elif option3 == 10: # Display data acc to type wise\n", | |
" print(\"1) Income\")\n", | |
" print(\"2) Expenditure\")\n", | |
" option3_10 = int(input(\"Please select option(1-2): \")) #storing option3_10 value selected by user\n", | |
" \n", | |
" if option3_10 == 1:\n", | |
" ty_ndf = ndf[(ndf['type'] == 'Income')] # assigning data of date enterd\n", | |
" print(ty_ndf[['type','wallets','amount','category','transcation_date','tags','comments']]) # displaying todays data of the user\n", | |
" elif option3_10 == 2:\n", | |
" ty_ndf = ndf[(ndf['type'] == 'Expenditure')] # assigning data of date enterd\n", | |
" print(ty_ndf[['type','wallets','amount','category','transcation_date','tags','comments']]) # displaying todays data of the user\n", | |
" else :\n", | |
" print('Wrong Input!!') #error message\n", | |
" \n", | |
" else: \n", | |
" print('Wrong Input!!') #error message\n", | |
"\n", | |
"else:\n", | |
" print('Wrong Input!!') #error message\n", | |
"\n", | |
" '''\n", | |
" #For calculator or inserting elements by adding them easily\n", | |
" a = input(\"Enter no\")\n", | |
" print(sum(list(map(int,a.split('+')))))\n", | |
" ''' " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 52, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"df_wallet = pd.DataFrame({'wallets':['Cash','Paytm']})\n", | |
"df_wallet3 = pd.DataFrame({'wallets':['C','P']})\n", | |
"writer = pd.ExcelWriter('test.xlsx')\n", | |
"df_wallet.to_excel(writer, sheet_name=\"Wallets\", index=False,engine='xlsxwriter') #inserting data of dataframe df (df) in the excel sheet\n", | |
"rdf_wallet = pd.read_excel('test.xlsx', sheet_name=\"Wallets\")\n", | |
"df_wallet3.to_excel(writer, sheet_name=\"abc\", index=False,engine='xlsxwriter') #inserting data of dataframe df (df) in the excel sheet\n", | |
"rdf_wallet3 = pd.read_excel('test.xlsx', sheet_name=\"abc\")\n", | |
"writer.save()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
" " | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.8" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment