0% found this document useful (0 votes)
33 views

Sample Project 1

Uploaded by

Devil Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
33 views

Sample Project 1

Uploaded by

Devil Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 14
SAMPLE PROJECT 1 a Description es ; Page No. 1 Certificate 223 2 Acknowledgement and References 224 3 || Introduction to. the Project 225 4 Source Code a 226-232 > ieee Screen 233 6 Hardware and Software Requirement 233124 Pogether week® Informatics Practices (Python)—!2 CERTIFICATE sect is developed by Computer Science Pro} he computer lab of Name> and under my supervision in in the session 2015-2016. The work done by them is original. Computer Science / Informatics Teacher Date:Sample Projects 125 ACKNOWLEDGMENT T would lik it i aa a tp expreis my sincere gratitude to my computer teacher for his snl ae ——— and encourage without which this project would not come forth from y side. me completing the project by giving i mt g the project by giving ideas, thoughts and made this project wish to thank my parents for their undivided support and interest who inspired me and encouraged ime to go my own way, Without which I would be unable to complete my project. REFERENCES 1. www.google.com/Python project 2. wwwawikepedia.com/Python and Pandas projects 3, Classnotes126 Poether with? Informatics Practic s (Python)—I2 INTRODUCTION TO THE PROJECT the Sales of any organisation, if we pass the any file in the same format. This project is used to an format ey. "Sales.csv". The project can analysis any sales data given The project is based on all the concepts learmt in the Class XI and XII. The project has capi to plot the graph , pivot the data and also print descriptive values. This project is createc help of different modules i.e. Bar Maker — Module is used to draw all the plots. Data Handler - To handle the data and apply all pivoting kind of the functions. Graph maker — To handle all other graphs. Main — This module is used to handle all other module and menus as well. Sample of Sales.CSV file Disses -Netepod fra Fae Et Format View Hel Item_Category, Item_Name, Price, Customer, Card Type Electronics, HP_Envy_Laptop, 2300, Joby George, Mastercard Grocery, Potato,65, Joby George, VISA Grocery, Tomato, 40, Joby George, VISA Clothing,Mens_Jeans,80,Jeff Jefferson,Mastercard Electronics,Samsung$10+,3000,Jeff Jefferson, VISA Grocery, Tomato, 40, Jeff Jefferson, VISA Grocery,Potato,65, Jeff Jefferson,Mastercard |Clothing,Ladies_Jeans,70,Charlie Wooden, VISA Electronics, SamsungS10+,3000,Charlie Wooden,Mastercard Stationary, faberCastle_Pens,30,Andrew Bottom, VISA Stationary, Flamingo_Notebook,50,Andrew Bottom,Mastercard Clothing, Mens_Jeans,80,Andrew Bottom,Mastercard Clothing, NIKE Running Shoes, 200,Andrew Bottom,Mastercard Clothing, Mens_Jeans,80 Andrew Bottonm,Mastercard Stationary,Maped_Sketchpens,20,Ridge June, VISA Electronics, Samsung$10+,3000,Ridge June, VISA Stationary,Flamingo_Notebook,50,Ridge June,Mastercard Electronics, JBLBluetoothSpeakers,600,Anne Garfield,Mastercard Stationary, FaberCastle_Pens,30,Anne Garfeild,VISAample Projects 427 SOURCE CODE import pandas as pd inport matplotlib.pyplot as plt import numpy as np def Gendnalysis(df) print('Welcone to Sales Analysis Project") sSecond File import pandas as pd import numpy as ap ef GenAnalysis(df): print(‘Wlecome to general analysis") total_sale + df[*Price’].sun() cnt_customers = len(df.pivot_table( index: with aggregate function as avg_sale = total_sale/ent_custoners #size to find nunver of non-cuplicates custoners items_sold = df{"Item_Name*].count() af_card = of.pivot_table(index =['Card_Type'J, agafunc = ‘count")[ Price’) best_card = df_card.loc{dt_card == df_card.nax()] “Custoner'], agatunc="size")) sve use pivot. table Print Results print (‘Totel Number of Customers visted: *, cnt_customers) print (‘Total Sale :",total_sale, ‘dhs') print (‘The average sale per custoner * ,avg_sale, ‘Ohs') print (‘Number of Items Sold itens_sold) print ("Host Popular card today sbest_card, index. tolist(), print('Press Enter to continue y ised: best_card. tolist(),"tines") input () def Sectionsnalysis(d£, sections) = print("Wlecome to section wise analysis’) saLooping across all possible £0" cateogry for value in sections print(‘Categotry Wise Analysis for" ,¥ e{' Item category’ ] =" value] falue, ‘Section: af_section = df.lecl¢128 Troecher eaeth® Informatics Practices (Python) —12 Compute Aggregates total sale = df['Price’].sum() size’) fe use pivor_ “Customer'], aggfun cot_custoners = len(df,pivot_table(index= table with aggregate function as avg_sale = total_sale/cnt_customers #size to find number of non-duplicates customers itens_sold = df['ItemNane" ].count() Pivot the table of a specific customer by categories and aggreagte function count to obtain money spent on each category d£_items = d£_section.pivot_table(index=['Item_Name'],aggfunc = ‘count')[‘Price’] *Use loc method find the category best_item = df_items.loc(df items == df!itens.max()] Printing Aggregates print (‘\tTotal Nunber of Customers: print (‘\tTotal Sale :',total_sale, ‘Dhs*) print (‘\tThe average sale per customer:',avg_sale, 'Dhs') »cnt_customers) print (‘\tNumber of Itens Sold: ',itens_sold) print (‘\tBest Selling item:',best_item. index. tolist(}, ‘sold’, best_item.tolist()) #1 use tolist function if there are multiple values print () print('Press Enter to continue input() def CustomerAnalysis(df, customers) : #8 Loop through choosen customers for key in custoner: print('Customer-wise analysis for’, key) df_customer = df.loc[d£[*Customer'] key) Computing Aggragates total_sale = df_customer[ 'Price’].sum() items_sold = df_custoner[‘Iten_Name' ].count() avg_sale = total_sale/items_sold *Pivot the table of a specific customer by categories and aggreagte function sum to obtain money spent on each category df_category = df_customer.pivot_table(index=['Item_Category’],aggfunc = ‘sum')['Price’] Use loc method find the categoryfav c3teGO1Y = Ff_category, toe gp on category aE _category max ( Di Printing results print (‘\tTotal sale ;+ print (‘\tThe average a print ("\tNumber of Tens boughts gett hs") print (‘\tFavourite ¢, sitems sold) Y ategory is: tolist(),“dhs") stiote since ae attccategon print () oe fhe «index. tolist(), table the categor print ("Press Enter to continue: ) input() seGendnalysis(df = pd.read_esv(‘sales_pay1.csy' )) import pandas as pd import matplotlib.pyplot as plt import numpy as np def GenAnalysis(df): #Sale BoxPlot plt. subplot (1, 2,1) plt.boxplot(df[ ‘Price’ ]) plt.title(‘Price per item sold') #CardGraph plt.subplot (1, 2,2) di_card = df.pivot_tal x = np.arange(Len(df_cazd) ) plt.bar(x,d£_card) “plt.title( ‘Most poular card i plt. show() pie(index =[*Card_Type" ],aggfune = “count')["Price'] n use’) def SectionAnalysis (df, sections): total_sale = [] cnt_customers = [] itens_sold = [] iso for value in sections: Sample Projects 429 ‘spent’, fav_category. ies bceome the indexPractices (Python)—12 130 Proerher eoieh® Informati d£_section = df. loc(dt{'Tten Category’ }-svalue] total_sale.append(dt_section{ ‘Price’ }-sun()) jot table (index=("Custoner' ], aggfunc='size’)) ) cnt_custoners.append(len(df_section. piv itens, cold.append(df_sect ion{ ‘Item ane’ ] count ()) sPivot the table of a specific iten by categories to obtain money spent on each category éf_items = Gf section, pivot _table index: [*Tten_Nane’ J, aggtunc = and aggreagte function count *count’)['Price'] Graph for ecah item sold in each category deed pit. figure(1) plt. subplot (2,2, i) x = np.arange(Len(d£_itens)) plt.bar(x,df_items.tolist()) plt.title(*Sale of items in ‘+value) plt.ylabel('Itens Sold’) pit. xticks(x,d£_items.index.tolist()) x = np.arange(len(sections)) Graph for total sale plt.figure(2) plt.subplot(2, 2,1) plt.bar(x, total_sale) plt.title('Total Sale across all the sections") plt.ylabel(‘Sale in Dhs.") plt.xticks(x, sections) aGraph for number of customers visted plt.subplot(2, 2,2) plt.bar(x,cnt_customers) plt.title('Number of vistors’) plt.xticks(x, sections) plt.ylabel('No-of people’) xGraph for number items sold plt.subplot(2, 2,3) plt. bar(x, itens_sold)plt.title( Number of tens so Sample Projects 134 ld") pit.xticks (x, sections) #Graph for plt.show() vet Custeneréralysis (4F,custoners, sections) #Find names of customers Using pivot_table and i t nd Loo, their purchases me(index = sections) df_custoner_sections = pd.Datarray for key in customers: df_customer = GE. loc [af ‘Customer* ] key] total_sale = [] Computing Aggragates total_sale. append(df_customer[ ‘Price']. sum()) sPivot the table of a specific custoner by categories and count to obtain money spent on each category df_category = d£_custoner. pivot_table (index=[‘Iten_Category"], aggfunc = ‘count’)['Price’] #Add this pivoted table to a record of different custoners df_customer_sections[key] = df_category t#Print the ‘dfCustomerSectionsCount’ datframe as a bar graph shift = 0 bar_size = len(customers)/100 for key ,value in df_customer_sections.iteritens() : np.arange(len(sections)) plt.bar(x+shift, value,width = bar_size,label = key) plt.xticks(x, sections) plt.legend(loc - ‘upper right") shift += bar_size plt.show() print(‘Press Enter to continue:') x input() (“sales_day5.csv'), [Andrew Botton’, ‘Anne Garfeild’, Vv -day5. : pd. read_cs *Stationary’]) a a. Ss i #CustomerAnalysis (| ‘Grocery’. “Joby George’ ],[ ‘Clothing’, Main File132 Pagceher eoith® Informatics Practices (Python)—12 import pandas as pd Inport natplotlib.pyplot as plt import nunpy as np def Gendnalysis(df): *Sale BoxPlot pit. subplot(1,2,1) plt.boxplot (dé{ 'Price’}) plt.title("Price per item sold’) #CardGraph plt.subplot(1,2,2) df_card = df.pivot_table(index x = np.arange(1en(df_card)) plt.bar(x,d£_card) plt.title('Most poular card in use’) pit. show() *card_Type'],aggfunc = ‘count'){*Price'] def SectionAnalysis(df, sections): total_sale = [] cnt_customers = [] items_sold = [] i-o for value in sections: df_section = df.loc[{df['Item Category’ |=-value] total_sale. append(df_section{ ‘Price’ ].sun()) cnt_custoners. append (1en(df_section. pivot_table(index=['Customer'], aggfunc='size'))) items_sold. append(df_section['Item_Name'].count()) sPivot the table of a specific item by categories and aggreagte function count to obtain money spent on each category df_items = df_section.pivot_table(index=[*Item Name'],agafunc = ‘count')[*Price'] Graph for each item sold in each category 1ects 133 Sample Proj pit. figure (1) pit. subplot (2,2, i) x = np.arange(len(df_items)) pit.bar(x,df_items. tolist()) pit.title('Sale of items in ‘+value) pit.ylabel (‘Items Sold’) plt.xticks (x,df_items. index.tolist()) x = np.arange(len(sections)) Graph for total sale pit. figure(2) plt.subplot(2,2,1) plt.bar(x, total_sale) plt.title(‘Total Sale across all the sections’) plt.ylabel('Sale in Dhs.") plt.xticks (x, sections) sGraph for number of customers visted pit. subplot (2,2,2) plt.bar(x,cnt_customers) plt.title('Number of vistors") plt.xticks(x, sections) plt.ylabel(‘No.of people”) sGraph for nunber items sold pit. subplot(2,2,3) plt.bar(x, items_sold) plt.title(‘Number of items sold’) plt.xticks (x, sections) Graph for pit. shou() def CustomerAnalysis (df, customers, sections): Find names of customers using pivot_table and loop their purchases d£_custoner_sections = pd.DataFrane(index = sections) for key in customers:134 apceher eceh® Informatics Practices (Python) —!2 d£_customer = df. loc{df{‘Custoner') == key] total_sale + () *Conputing Agaragates total_sale. append(df_custoner| Price’ }.sun()) sPivot the table of a specific custoner by categorie spent on each category ee ee f_category = d£_customer.pivot_table(index:[‘Iten_Category J, agg£unc = rice’ ] dd this pivoted table to a record of different customers 5 and count to obtain money f_custoner_sections[key] = df_category #sPrint the ‘dfCustonexSectionsCount’ datfrane as a bar graph shift = 0 bar_size = len(custoners)/100 for key ,value in df_custoner_sections. iteritens() x = np.arange(len(sections)) plt.bar(xeshift, value,width = bar_size, label = key) plt.xticks (x, sections) plt.legend(1oc = ‘upper right") shift += bar_size plt.show() print (‘Press Enter to continue:') input () ##CustonerAnalysis (pd. read_csv(‘sales_day5.csv'), [Andrew Bottom’, ‘Anne Garfeild’, “Joby George'],['Clothing’, ‘Grocery’, ‘Stationary’ ])Sample Projects 135 OUTPUT SCREEN Jonensteen - 3 pytnon 3.6.5 (V3.6.5:£59C0932b4, Mar 28 2018, 16:07:46) (MSC v.1900 32 bit (inte 1)] on win32 Type "copyright", “credits” or “license()" for more information. >>> RESTART: C:\Users\Krrishnav\Desktop\Classs XII -IP projects\Naveen [P\nain.py ‘Welcome to Bill Management* 1, Upload CSV file 2. Help uploading CSV file Enter your option Oitprmwnen HARDWARE & SOFTWARE REQUIREMENT Hardware Requirement Pentium 3/4/Core 2 Duo/Dual core/i3/iSA7 With at least 256 MB RAM 2MB free space on Hard Disk Color Monitor/LCD Operating System & Compiler MS Windows Python with related libraries used of Data Analysis © Pandas © Numpy © Matplotlib

You might also like