Untitled
unknown
plain_text
2 years ago
7.2 kB
4
Indexable
import matplotlib.pyplot as plt from sqlalchemy import create_engine my_conn=create_engine("mysql+mysqldb://root:pervysage2004@localhost/project") import pandas as pd import webbrowser as wb import numpy as np d1={'Driver':['Mangal','Ayush','Shrey','Nakul','Darsh','Dhruv','Arnab','Praveen','Nitin','Mayank'], 'ID':[2314,5543,6789,2378,1234,6699,6969,1023,9872,6102], 'Distance Covered (KM)':[106,506,1500,23,45,77,893,123,156,223], 'Charge Per KM':[10,9,15,13,12,22,25,20,10,11], 'Area':['Noida','Noida','Delhi','Delhi','Gurgaon','Delhi','Noida','Delhi','Noida','Gurgaon']} df=pd.DataFrame(d1) d2={'Mangal':9971822778,'Ayush':9627804321,'Shrey':9627804030,'Nakul':9255678910,'Darsh':9081762369,'Dhruv':9010225578,'Arnab':8970554422,'Praveen':9971822775,'Nitin':9976129045,'Mayank':9837188555} d3={'Mangal':'Swift/UP265378','Ayush':'Ertiga/UP266908','Shrey':'i10/DL1C8264','Nakul':'Scorpio/DL1C5612','Darsh':'Indica/HR261324','Dhruv':'Bolero/DL1C6689','Arnab':'i20/UP264569','Praveen':'Honda City/DL1C7472','Nitin':'Camry/UP269009','Mayank':'Santro/HR265873'} s1=pd.Series(d2) s2=pd.Series(d3) n=input('Enter Your Name: ') print(f'Welcome {n}!') print('Welcome To Menu,Here are the commands you can run: ') print('1.Cab Booking') print('2.DataFrame View') print('3.Visualization Of The Dataframe') print('4.Alter Dataframe') print('5.Exit') k=int(input('Choose The Command:')) if k==0 or k>5: while k==0 or k>5: print('1.Cab Booking') print('2.DataFrame View') print('3.Visualization Of The Dataframe') print('4.Alter Dataframe') print('5.Exit') k=int(input('Please Choose From The Following:')) while k>=1 and k<=5: if k==0 or k>5: while k==0 or k>5: print('1.Cab Booking') print('2.DataFrame View') print('3.Visualization Of The Dataframe') print('4.Alter Dataframe') print('5.Exit') k=int(input('Please Choose From The Following:')) elif k==1: print('Welcome to Uber Where Rides are Convenient for Everyone ') print('type 0 if want to quit booking') l=int(input('Enter Number of Booking: ')) for i in range(0,l,1): if l=='0': break; print('Areas we operate in:','\nDelhi','\nGurgaon','\nNoida') b=input('Please select your Area:') d=b.capitalize() print('Drivers near your location along their charges:') print(df.loc[df['Area']==d,['Driver','Charge Per KM']]) print('Select Your Driver As Per Your Convenience By Typing their respective Number') print('example','\n0 or 7') c=int(input('Enter:')) dr=df['Driver'][c] print(f'Your Driver Is:{dr}') print('Here Are The Details Of Your Driver :') print(s1[dr]) print(s2[dr]) e=input('Enter Place You Want To Reach: ') print('Below You will find the link to google maps pls click on it to enter the place and tell the distance to be covered') link=wb.open('https://www.google.com/maps/') print(link) f=int(input('Enter Distance: ')) pr=d1['Charge Per KM'][c] pr=np.array(pr) pr=int(pr) pr=pr*f print(f'Your Price Is:{pr} ') print('Thank You For Booking and Enjoy Your Trip!') df.loc[c,'Distance Covered (KM)']=df.loc[c,'Distance Covered (KM)']+f print('Booking Over') print('Updated The Dataframe in terms of distance covered') z=input('Do You Wish To see The Updated Dataframe?[Y/N]:') z=z.capitalize() if z=='Y': print(df) print() elif k==4: print('1.Adding new records') print('2.Deleting records') s=int(input('Please Select the following:')) while s==1 or s==2: if s==1: print(df) print('Please give the details accordingly') l1=[] for p in range(1,6): q=input('Enter value:') l1.append(q) l1[1]=int(l1[1]) l1[2]=int(l1[2]) df.loc[len(df)]=l1 print('Updated dataframe') print(df) if s==2: q=input('Please tell if u wanna delete row or column:[R/C]:') q=q.capitalize() if q=='R': print('Which row u wanna delete from the following') print(df) z=df.index z=z.tolist() print(z) w=int(input('Enter:')) df.drop(labels=[w],inplace=True) print('Updated dataframe') print(df) elif q=='C': print('which column you wanna delete') print(df) z=df.columns z=z.tolist() print(z) w=input('Enter:') df.drop(columns=[w],inplace=True) print('Updated dataframe') print(df) print('enter 0 to quit the alteration') print('1.Adding new records') print('2.Deleting records') s=int(input('Please Select the following:')) elif k==2: print('The Database:') print() print(df) elif k==3: pass; a=df.Area a=a.tolist() b=[] c=df.Area.drop_duplicates(keep='last') c=c.tolist() for i in c: e=df.loc[df['Area']==i,'Area'] e=e.count() b.append(e) plt.bar(a,b,color='b') plt.xlabel('city we operate') plt.ylabel('no. of drivers present in that city') plt.title('Driver available in the city we operate in ') plt.show() x=df.Driver y=df['Distance Covered (KM)'] plt.plot(x,y,color='r') plt.xlabel('DRIVERS') plt.ylabel('DISTANCE THEY COVERED') plt.title('EACH DRIVER AND DISTANCE THEY COVERED') plt.show() p=df.Driver q=df['Charge Per KM'] plt.bar(p,q,color='g') plt.xlabel('DRIVERS') plt.ylabel('CHARGE PER KM') plt.title('EACH DRIVER AND DISTANCE THEY CHARGE') plt.show() else: print('Session Over') break; print('1.Cab Booking') print('2.DataFrame View') print('3.Visualization Of The Dataframe') print('4.Alter Dataframe') print('5.Exit') k=int(input('Please Choose From The Following:')) df.to_sql(con=my_conn,name='project',if_exists='replace',index=False)
Editor is loading...