CODING & OUTPUT Bike Data Analysis
CODING & OUTPUT Bike Data Analysis
Code
end_msg='''
Project Made by Prateek singh
Guru Harkrishan Public School, Kalkaji, New Delhi-110019
Thank You'''
main_menu='''\n
-------MAIN MENU----------
1. Result Data Import To DataFrame or Export TO CSV File
2. Result Data Anyalysis/Data Manipulation
3. Result Data Visualization
4. Exit'''
analysis_menu='''\n --------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu'''
'''for i in intro:
print(i,end='')
time.sleep(0.0001) '''
while True:
print(main_menu)
ch=int(input('Enter your choice -> '))
if ch==1:
while True:
print(import_export_menu)
ch3=int(input('Enter your choice -> '))
if ch3==1:
df= pd.read_csv('E:/Project IP 2020/Prateek/Bike data
analysis.csv',index_col=0)
pd.set_option('display.expand_frame_repr',False) #To
display data in expanded form
pd.set_option('display.max_rows',50) #To display all
rows on screen
print('Content of data frame ')
print(df)
print()
elif ch3==2:
df.to_csv("bike data.csv", index = False, header=True)
print('\nData Written in [bike data.csv]
file.........\n\n')
elif ch3==3:
print('\n.........Back to Main menu........\n\n')
break
else:
print('\nWrong Choice\n')
elif ch==2:
while True:
print(analysis_menu)
ch1=int(input('Enter your choice -> '))
if ch1==1:
print(df)
print()
elif ch1==2:
print('\nList of Columns are [')
for x in df.columns:
print(x,end=', ')
print(' ]')
clist=[]
while True:
c=input('\nEnter column name -> ')
clist.append(c)
ch=input('Want to give more column name-> ')
if ch in 'nN':
break
print('Details of Selected columns data')
print(df[clist])
print()
elif ch1==3:
print('Name of companies ',df.company.unique())
n=input('\nEnter company Name ')
df1=df[df.company==n]
if df1.empty:
print('\n.......sorry no data for this
group........')
else:
print(df1)
print()
elif ch1==4:
print('\nList of bike model ->
',df.bikemodel.unique())
st=input('\nEnter bike model -> ')
df1=df[df.bikemodel==st]
if df1.empty:
print('\nNo Record is available for -> ',st)
else:
print(df1)
print()
elif ch1==5:
y=int(input('\nEnter cubic capacity :
[100,110,125,135,150,180,200,220,350,500] -> '))
df1=df[df['capacity(cc)']==y]
if df1.empty:
print('\n.........Sorry No Record Exist.........\
n')
else:
print(df1)
print()
elif ch1==6:
print('\nAvailable Record Numbers Range ->
',df.index)
n=eval(input('\nEnter Row numbers for which you want
to display record -> '))
df1=df.iloc[n] # df.loc[n]
if df1.empty:
print('\n........Sorry Records not exist........\
n')
else:
print(df1)
print()
elif ch1==7:
print('\nbike model where price upto 55000 and average
more than 50 -> \n ')
df1=df.loc[(df.price <=55000) & (df.average>50), :]
if df1.empty:
print('\n.......Sorry such records exist......\n')
else:
print(df1)
print()
elif ch1==8:
g=df.groupby('company')
print('\nCompany wise Maximum price of bikes\n')
df1=g.max()
if df1.empty:
print('\n........Sorry Record Not Found..........\
n')
else:
print(df1)
print()
elif ch1==9:
print('\nTop five records are ')
print(df.head())
print()
elif ch1==10:
print('\nLast five records are ')
print(df.tail())
print()
elif ch1==11:
st=input('Enter bike model: ')
cc=int(input('Enter capacity in CC: '))
av=int(input("Enter average']: "))
comp=input('Enter company : ')
p=int(input('Enter price : '))
#L=[st,cc,av,comp,p]
#n=int(input('\n\nEnter the index number for new
record -> '))
#df.loc[n]=L # this command replace existing row,
beneficial for update
df=df.append({'bikemodel':st,'capacity(cc)':cc,'average':av,
'company':comp,'price':p},
ignore_index=True)
print('\n.........Record inserted...........\n')
elif ch1==12:
n=int(input('Enter the row index number for deletion -
> '))
df.drop(n,inplace=True)
print('\n------------Record deleted---------------')
elif ch1==13:
col=input('\nEnter the column name to be added -> ')
df[col]=[x for x in range(len(df))]
print(df)
print('\n-----------Column added--------')
elif ch1==14:
print('\nColumns Details ')
print(df.info())
print()
elif ch1==15:
print('\nDescriptive Statistics ')
print(df.describe())
print()
elif ch1==16:
print('\n.........Back to Main menu........\n\n')
break
else:
print('\nWrong Choice\n')
elif ch==3:
while True:
print(plot_menu)
ch2=int(input('\nEnter your choice -> '))
if ch2==1:
model=df.bikemodel
price=df.price
x=range(len(df.bikemodel))
plt.plot(price,marker='o')
plt.xticks(x,df.bikemodel,rotation=90)
plt.xlabel('bike model')
plt.ylabel('Price')
plt.grid(True)
plt.show()
elif ch2==2:
model=df.bikemodel
df.plot('bikemodel','average',kind='bar',color='m',edgecolor='g')
plt.ylabel('Average',fontsize=12)
plt.xlabel('Bike Models',fontsize=12)
plt.title('Bike models VS Average',fontsize=14)
plt.subplots_adjust(bottom=0.35) #Margin beteen X-
axis and bottom of chart window
plt.show()
elif ch2==3:
df.plot('bikemodel','price',kind='bar',color='g',edgecolor='y')
plt.ylabel('Bike Model',fontsize=10)
plt.xlabel('Price',fontsize=10)
plt.title('Bike model VS price',fontsize=12)
plt.show()
elif ch2==4:
df.hist()
plt.show()
elif ch2==5:
print('\n.........Back to Main menu........\n\n')
break
else:
print('\nWrong Choice\n')
else:
for i in end_msg:
print(i,end='')
time.sleep(0.0001)
break
OUTPUT
-------MAIN MENU----------
1. Result Data Import To DataFrame or Export TO CSV File
2. Result Data Anyalysis/Data Manipulation
3. Result Data Visualization
4. Exit
Enter your choice -> 1
------IMPORT/EXPORT MENU------
1. Import CSV to DataFrame
2. Export DataFrame Data to CSV File
3. Return to Main Menu
Enter your choice -> 1
Content of data frame
bikemodel capacity(cc) average company price
Sno
1 Splendor 110 60 hero motocorps 54000
2 platina 100 55 bajaj auto 60000
3 CD deluxe 110 55 hero motocorps 57000
4 radeon 110 58 tvs motors 59000
5 discover 125 50 bajaj auto 60000
6 pulsar 135 45 bajaj auto 65000
7 pulsar 150 40 bajaj auto 70000
8 pulsar 200 38 bajaj auto 98000
9 star city 125 50 tvs motors 45000
10 gixxer 200 40 suzuki motors 80000
11 KTM 350 35 duke motors 160000
12 classic 350 350 45 royal enfield 150000
13 fz-5 180 40 yamaha motors 75000
14 YZF-R15 220 35 yamaha motors 180000
15 haybusa 300 35 suzuki motors 160000
16 apache RTR 220 40 tvs motors 95000
17 avenger 135 45 bajaj auto 75000
18 victor 135 50 tvs motors 65000
19 vikrant 150 45 tvs motors 60000
20 passion 135 40 hero motocorps 65000
21 thunderbird 500 350 40 royal enfield 130000
22 excel 100 55 tvs motors 37000
23 impulse 220 45 hero motocorps 80000
24 CT100 100 50 bajaj auto 65000
25 rajdoot 150 40 yamaha motors 73000
------IMPORT/EXPORT MENU------
1. Import CSV to DataFrame
2. Export DataFrame Data to CSV File
3. Return to Main Menu
Enter your choice -> 3
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 1
bikemodel capacity(cc) average company price
Sno
1 Splendor 110 60 hero motocorps 54000
2 platina 100 55 bajaj auto 60000
3 CD deluxe 110 55 hero motocorps 57000
4 radeon 110 58 tvs motors 59000
5 discover 125 50 bajaj auto 60000
6 pulsar 135 45 bajaj auto 65000
7 pulsar 150 40 bajaj auto 70000
8 pulsar 200 38 bajaj auto 98000
9 star city 125 50 tvs motors 45000
10 gixxer 200 40 suzuki motors 80000
11 KTM 350 35 duke motors 160000
12 classic 350 350 45 royal enfield 150000
13 fz-5 180 40 yamaha motors 75000
14 YZF-R15 220 35 yamaha motors 180000
15 haybusa 300 35 suzuki motors 160000
16 apache RTR 220 40 tvs motors 95000
17 avenger 135 45 bajaj auto 75000
18 victor 135 50 tvs motors 65000
19 vikrant 150 45 tvs motors 60000
20 passion 135 40 hero motocorps 65000
21 thunderbird 500 350 40 royal enfield 130000
22 excel 100 55 tvs motors 37000
23 impulse 220 45 hero motocorps 80000
24 CT100 100 50 bajaj auto 65000
25 rajdoot 150 40 yamaha motors 73000
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 2
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 3
Name of companies ['hero motocorps' 'bajaj auto' 'tvs motors' 'suzuki
motors' 'duke motors'
'royal enfield' 'yamaha motors']
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 4
List of bike model -> ['Splendor' 'platina ' 'CD deluxe' 'radeon
' 'discover' 'pulsar'
'star city' 'gixxer' 'KTM' 'classic 350' 'fz-5' 'YZF-R15' 'haybusa'
' apache RTR' 'avenger' 'victor' 'vikrant' 'passion' 'thunderbird
500'
'excel' 'impulse' 'CT100' 'rajdoot']
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 6
Enter Row numbers for which you want to display record -> 12
bikemodel fz-5
capacity(cc) 180
average 40
company yamaha motors
price 75000
Name: 13, dtype: object
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 7
bike model where price upto 55000 and average more than 50 ->
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 9
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 10
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 11
Enter bike model: rajdoot
Enter capacity in CC: 150
Enter average']: 45
Enter company : yamaha motors
Enter price : 78000
.........Record inserted...........
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 1
bikemodel capacity(cc) average company price
0 Splendor 110 60 hero motocorps 54000
1 platina 100 55 bajaj auto 60000
2 CD deluxe 110 55 hero motocorps 57000
3 radeon 110 58 tvs motors 59000
4 discover 125 50 bajaj auto 60000
5 pulsar 135 45 bajaj auto 65000
6 pulsar 150 40 bajaj auto 70000
7 pulsar 200 38 bajaj auto 98000
8 star city 125 50 tvs motors 45000
9 gixxer 200 40 suzuki motors 80000
10 KTM 350 35 duke motors 160000
11 classic 350 350 45 royal enfield 150000
12 fz-5 180 40 yamaha motors 75000
13 YZF-R15 220 35 yamaha motors 180000
14 haybusa 300 35 suzuki motors 160000
15 apache RTR 220 40 tvs motors 95000
16 avenger 135 45 bajaj auto 75000
17 victor 135 50 tvs motors 65000
18 vikrant 150 45 tvs motors 60000
19 passion 135 40 hero motocorps 65000
20 thunderbird 500 350 40 royal enfield 130000
21 excel 100 55 tvs motors 37000
22 impulse 220 45 hero motocorps 80000
23 CT100 100 50 bajaj auto 65000
24 rajdoot 150 40 yamaha motors 73000
25 rajdoot 150 45 yamaha motors 78000
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 12
Enter the row index number for deletion -> 25
------------Record deleted---------------
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 1
bikemodel capacity(cc) average company price
0 Splendor 110 60 hero motocorps 54000
1 platina 100 55 bajaj auto 60000
2 CD deluxe 110 55 hero motocorps 57000
3 radeon 110 58 tvs motors 59000
4 discover 125 50 bajaj auto 60000
5 pulsar 135 45 bajaj auto 65000
6 pulsar 150 40 bajaj auto 70000
7 pulsar 200 38 bajaj auto 98000
8 star city 125 50 tvs motors 45000
9 gixxer 200 40 suzuki motors 80000
10 KTM 350 35 duke motors 160000
11 classic 350 350 45 royal enfield 150000
12 fz-5 180 40 yamaha motors 75000
13 YZF-R15 220 35 yamaha motors 180000
14 haybusa 300 35 suzuki motors 160000
15 apache RTR 220 40 tvs motors 95000
16 avenger 135 45 bajaj auto 75000
17 victor 135 50 tvs motors 65000
18 vikrant 150 45 tvs motors 60000
19 passion 135 40 hero motocorps 65000
20 thunderbird 500 350 40 royal enfield 130000
21 excel 100 55 tvs motors 37000
22 impulse 220 45 hero motocorps 80000
23 CT100 100 50 bajaj auto 65000
24 rajdoot 150 40 yamaha motors 73000
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 14
Columns Details
<class 'pandas.core.frame.DataFrame'>
Int64Index: 25 entries, 0 to 24
Data columns (total 5 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 bikemodel 25 non-null object
1 capacity(cc) 25 non-null int64
2 average 25 non-null int64
3 company 25 non-null object
4 price 25 non-null int64
dtypes: int64(3), object(2)
memory usage: 1000.0+ bytes
None
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 15
Descriptive Statistics
capacity(cc) average price
count 25.000000 25.000000 25.000000
mean 178.400000 45.240000 84720.000000
std 80.979936 7.406529 39375.880943
min 100.000000 35.000000 37000.000000
25% 125.000000 40.000000 60000.000000
50% 150.000000 45.000000 70000.000000
75% 220.000000 50.000000 95000.000000
max 350.000000 60.000000 180000.000000
--------SEARCH/ADDITION/DELETION--------
1. Dispaly All Records
2. Search Records based on Selected Column
3. Search Records based on company name
4. Search Records based on model of bike
5. Search Records based on a cubic capacity
6. Search Records based on Row Label/Number(loc[]/iloc[])
7. bike models where price upto 55000 and average more than 50
8. bike models where price is maximum for each company
9. Top Five Records
10. Last Five Records
11. Addition of a New Record to DataFrame
12. Deletion of Reocrds from DataFrame
13. Addition of a New Column to DataFrame
14. Display dataframe information
15. Display description of DataFrame(aggregate functions)
16. Return to Main Menu
Enter your choice -> 16
-------MAIN MENU----------
1. Result Data Import To DataFrame or Export TO CSV File
2. Result Data Anyalysis/Data Manipulation
3. Result Data Visualization
4. Exit
Enter your choice -> 3
----PLOT MENU----
1. Line Plot(bike model Vs Price)
2. Bar Plot(bike model Vs average)
3. Bar Plot(bike model Vs price)
4. Histogram
5. Return to Main Menu
----PLOT MENU----
1. Line Plot(bike model Vs Price)
2. Bar Plot(bike model Vs average)
3. Bar Plot(bike model Vs price)
4. Histogram
5. Return to Main Menu
-------MAIN MENU----------
1. Result Data Import To DataFrame or Export TO CSV File
2. Result Data Anyalysis/Data Manipulation
3. Result Data Visualization
4. Exit
Enter your choice -> 4
Thank You