0% found this document useful (0 votes)
22 views11 pages

LENOVO Store IP class 12 project part 2

Uploaded by

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

LENOVO Store IP class 12 project part 2

Uploaded by

jenitaalex21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

import pandas as pd

import matplotlib.pyplot as plt

print('\n')
print(70*'*')
print('\t\t\t\t********** LENOVO SHOPPING STORE **********')
print('*** List of Dell Products ***')
print('1. Display the Details of Laptops...')
print('2. Display the Details of Desktops...')
print(70*'*')
print('*** LENOVO Products Data Visualization ***')
print('3. Display Laptops Data by using Line Graphs...')
print('4. Display Laptops Data by using Bar Graphs...')
print('5. Display Desktops Data by using Line Graphs...')
print('6. Display Desktops Data by using Bar Graphs...')
print(70*'=')
print('*** Data Manipulation ***')
print('7. Inserting A New Product Record...')
print('8. Deleting A Product Record...')
print('9. Updating A Product Record...')
print('10. Searching A Record...')
print('11. Arrange the Product Data accordingly...')
print('12. Read Top And Bottom Records From File As Required...')
print('13. Exit...')
print(70*'=')

ch= input('Enter Your Choice: ')

if ch=='1':
print('Reading Laptop Data From CSV File...')
df=pd.read_csv("D:\Laptop 1.csv",sep=",",header=0)
print(df)

elif ch=='2':
print('Reading Desktop Data From CSV File...')
df=pd.read_csv("D:\Desktop 2.csv",sep=",",header=0)
print(df)

elif ch=='3':
df = pd.read_csv("D:\Laptop 1.csv",sep=",",header=0)
name = df['Laptop Name']
qn = df['Stock']
pr = df['Price']
ra = df['Ratings']
un_b = df['Units Booked']
un_s = df['Units Sold']

plt.xlabel('Laptop Name')
plt.xticks(rotation = 90)

print('Select Specific Line Chart As Given Below: ')


print('Press 1 To Print The Data For Laptops vs Stock...')
print('Press 2 To Print The Data For Laptops vs Price...')
print('Press 3 To Print The Data For Laptops vs Ratings....')
print('Press 4 To Show The Data For Laptops vs Units Booked...')
print('Press 5 To Show The Data For Laptops vs Units Sold...')
op=int(input("Choose Your Desired Option"))

if op==1:
plt.ylabel('Stock')
plt.title('*** Laptops vs Stock ***')
plt.yticks(range(0,60,5))
plt.plot(name,qn,marker='d')
plt.show()
elif op==2:
plt.ylabel('Price')
plt.title('*** Laptops vs Price ***')
plt.yticks()
plt.plot(name,pr,marker='h')
plt.show()
elif op==3:
plt.ylabel('Rating (out of 5)')
plt.title('*** Laptops vs Rating ***')
plt.yticks(range(0,6,1))
plt.plot(name,ra, marker='*')
plt.show()
elif op==4:
plt.ylabel('Units Booked')
plt.title('*** Laptops vs Units Booked ***')
plt.yticks(range(0,30,2))
plt.plot(name,un_b,marker='d')
plt.show()
elif op==5:
plt.ylabel('Units Booked')
plt.title('*** Laptops vs Units Booked ***')
plt.yticks(range(0,30,2))
plt.plot(name,un_s,marker='d')
plt.show()
else:
print('Enter a Valid Input...')

elif ch=='4':
df= pd.read_csv("D:\Laptop 1.csv",sep=",",header=0)
name = df['Laptop Name']
qn = df['Stock']
pr = df['Price']
ra = df['Ratings']
un_b = df['Units Booked']
un_s = df['Units Sold']

plt.xlabel('Laptop Name')
plt.xticks(rotation = 90)

print('Select Specific Bar Chart As Given Below: ')


print('Press 1 To Print The Data For Laptops vs Quantity...')
print('Press 2 To Print The Data For Laptops vs Price...')
print('Press 3 To Print The Data For Laptops vs Ratings....')
print('Press 4 To Show The Data For Laptops vs Units Booked...')
print('Press 5 To Show The Data For Laptops vs Units Sold...')

op=int(input("Choose Your Desired Option"))

if op==1:
plt.ylabel('Stock')
plt.title('*** Laptops vs Stock ***')
plt.yticks(range(0,50,5))

plt.bar(name,qn)
plt.show()
elif op==2:
plt.ylabel('Price')
plt.title('*** Laptops vs Price ***')
plt.yticks(range(25000,150000,20000))

plt.bar(name,pr)
plt.show()
elif op==3:
plt.ylabel('Ratings (out of 5)')
plt.title('*** Laptops vs Ratings ***')
plt.yticks(range(0,6,1))

plt.bar(name,ra)
plt.show()
elif op==4:
plt.ylabel('Units Booked')
plt.title('*** Laptops vs Units Booked ***')
plt.yticks(range(0,30,2))
plt.bar(name,un_b)
plt.show()
elif op==5:
plt.ylabel('Units Booked')
plt.title('*** Laptops vs Units Booked ***')
plt.yticks(range(0,30,2))
plt.bar(name,un_s)
plt.show()
else:
print('Enter a Valid Input...')

elif ch=='5':
df= pd.read_csv("D:\Desktop 2.csv",sep=",",header=0)
name = df['Desktop Model']
qn = df['Stock']
pr = df['Price']
ra = df['Ratings']
un_b = df['Units Booked']
un_s = df['Units Sold']

plt.xlabel('Desktop Model')
plt.xticks(rotation = 90)

print('Select Specific Line Chart As Given Below: ')


print('Press 1 To Print The Data For Desktop vs Stock...')
print('Press 2 To Print The Data For Desktop vs Price...')
print('Press 3 To Print The Data For Desktop vs Ratings....')
print('Press 4 To Show The Data For Desktop vs Units Booked...')
print('Press 5 To Show The Data For Desktop vs Units Sold...')

op=int(input("Choose Your Desired Option"))

if op==1:
plt.ylabel('Stock')
plt.title('*** Desktop vs Stock ***')
plt.yticks(range(0,50,5))

plt.plot(name,qn,marker='d')
plt.show()

elif op==2:
plt.ylabel('Price')
plt.title('*** Desktop vs Price ***')
plt.yticks(range(25000,150000,20000))

plt.plot(name,pr,marker='h')
plt.show()
elif op==3:
plt.ylabel('Ratings (out of 5)')
plt.title('*** Desktop vs Ratings ***')
plt.yticks(range(0,6,1))

plt.plot(name,ra, marker='*')
plt.show()
elif op==4:
plt.ylabel('Price')
plt.title('*** Desktop vs Units Booked ***')
plt.yticks(range(0,40,2))

plt.plot(name,un_b,marker='h')
plt.show()
elif op==5:
plt.ylabel('Ratings (out of 5)')
plt.title('*** Desktop vs Units Sold ***')
plt.yticks(range(0,40,2))

plt.plot(name,un_s, marker='*')
plt.show()

else:
print('Enter a Valid Input...')

elif ch=='6':
df= pd.read_csv("D:\Desktop 2.csv",sep=",",header=0)
name = df['Desktop Model']
qn = df['Stock']
pr = df['Price']
ra = df['Ratings']
un_b = df['Units Booked']
un_s = df['Units Sold']

plt.xlabel('Desktop Name')
plt.xticks(rotation = 90)

print('Select Specific Bar Chart As Given Below: ')


print('Press 1 To Print The Data For Desktop vs Stock...')
print('Press 2 To Print The Data For Desktop vs Price...')
print('Press 3 To Print The Data For Desktop vs Ratings....')
print('Press 4 To Show The Data For Desktop vs Units Booked...')
print('Press 5 To Show The Data For Desktop vs Units Sold...')
op = int(input('Choose Your Desired Option :'))

if op==1:
plt.ylabel('Stock')
plt.title('*** Desktop vs Stock ***')
plt.yticks(range(0,50,5))
plt.bar(name,qn)
plt.show()
elif op==2:
plt.ylabel('Price')
plt.title('*** Desktop vs Price ***')
plt.yticks(range(25000,150000,10000))
plt.bar(name,pr)
plt.show()
elif op==3:
plt.ylabel('Rating (out of 5)')
plt.title('*** Desktop vs Rating ***')
plt.yticks(range(0,6,1))
plt.bar(name,ra)
plt.show()
elif op==4:
plt.ylabel('Price')
plt.title('*** Desktop vs Units Booked ***')
plt.yticks(range(0,40,2))

plt.bar(name,un_b)
plt.show()
elif op==5:
plt.ylabel('Ratings (out of 5)')
plt.title('*** Desktop vs Units Sold ***')
plt.yticks(range(0,40,2))

plt.bar(name,un_s)
plt.show()

else:
print('Enter a Valid Input...')

elif ch=='7':
print('Insert New Data in a CSV File...')
print('Press 1 To Insert Data of Laptop...')
print('Press 2 To Insert Data of Desktop...')

ch= int(input('Enter your CSV choice: '))

if ch==1:
df=pd.read_csv("D:\Laptop 1.csv",sep=",",header=0)
a = int(input("Enter index : "))
b = int(input("Enter ID: "))
c = input("Enter Laptop Name: ")
d = int(input(" Enter Price: "))
e = float(input("Enter Ratings: "))
f = int(input("Enter Stock: "))
g = int(input("Enter Units Booked"))
h = int(input("Enter Units Sold"))
df.loc[a]=[b,c,d,e,f,g,h]
df.to_csv(path_or_buf="D:\Laptop 1.csv",sep=",")
print()
print(df)
print()
print("New Laptop Details Added...")
elif ch==2:
df=pd.read_csv("D:\Desktop 2.csv",sep=",",header=0)
a = int(input("Enter Index"))
b = input("Enter ID(unique): ")
c = input("Enter Desktop Name: ")
d = int(input("Enter Price of Desktops: "))
e = float(input("Enter Rating of Desktop: "))
f = int(input("Enter Stock of Desktops: "))
g = int(input("Enter Units Booked"))
h = int(input("Enter Units Sold"))

df.loc[a]=[b,c,d,e,f,g,h]
df.to_csv(path_or_buf="D:\Desktop 2.csv",sep=",")
print()
print(df)
print()
print("New Desktop Details added")
else:
print('Enter a Valid Input...')

elif ch=='8':
print('Delete The Data from a CSV File...')
print('Press 1 To Delete Data From Laptop...')
print('Press 2 To Delete Data From Desktop...')

ch= int(input('Enter your CSV choice: '))

if ch==1:
df=pd.read_csv("D:\Laptop 1.csv",sep=",",header=0)
a = int(input("Enter Index: "))
df.drop(a,inplace=True)
df.to_csv(path_or_buf="D:\Laptop 1.csv",sep=",")
print()
print(df)
print()
print("Laptop Details Removed...")
elif ch==2:
df=pd.read_csv("D:\Desktop 2.csv",sep=",",header=0)
a = int(input("Enter S.No. : "))
df.drop(a,inplace=True)
df.to_csv(path_or_buf="D:\Desktop 2.csv",sep=",")
print()
print(df)
print()
print("Desktop Details Removed...")
else: print('Enter Valid Choice...')

elif ch=='9':
print('Update Data in a CSV File...')
print('Press 1 To Update Data of Laptop...')
print('Press 2 To Update Data of Desktop...')
ch= int(input('Enter your CSV choice: '))
if ch==1:
df=pd.read_csv("D:\Laptop 1.csv",sep=",",header=0)
a = int(input("Enter Index no.: "))
print("Current ID is: ",df.loc[a,"ID"])
df.loc[a,"ID"] = input("Enter New Laptop ID: ")
print("Current Laptop Name is: ",df.loc[a, "Laptop Name"])
df.loc[a, "Laptop Name"] = input("Enter New Laptop Name: ")
print("Current Price of Laptop is: ",df.loc[a,"Price"])
df.loc[a,"Price"] = int(input("Enter New Price of Laptop: "))
print("Current Rating of Laptop is: ",df.loc[a,"Ratings"])
df.loc[a, "Ratings"] = float(input("Enter New Rating of Laptop :
"))
df=pd.to_csv(path_or_buf="D:\Laptop 1.csv",sep=",")
print("Current Stock is: ",df.loc[a, "Stock"])
df.loc[a,"Stock"] = int(input("Enter New Stock of Laptops: "))
print("Current Number of Units Sold is: ",df.loc[a,"Units Sold"])
df.loc[a,"Units Sold"] = input("Enter Updated number of Laptop
Units Sold: ")
print("Current Number of Units Booked is: ",df.loc[a,"Units
Booked"])
df.loc[a,"Units Booked"] = input("Enter Updated number of Laptop
Units Booked: ")

df=pd.to_csv(path_or_buf="D:\Laptop 1.csv",sep=",")
print()
print(df)
print()
print("Laptop Details Updated...")
elif ch==2:
df=pd.read_csv("D:\Desktop 2.csv",sep=",",header=0)
a = int(input("Enter Index No.: "))
print("Current Desktop ID is: ",df.loc[a,"ID"])
df.loc[a,"ID"] = input("Enter New Desktop ID: ")
print("Current Desktop Model is: ",df.loc[a, "Desktop Model"])
df.loc[a,"Desktop Model"] = input("Enter New Desktop Model: ")
print("Current Price is: ",df.loc[a, "Price"])
df.loc[a, "Price"] = int(input("Enter New Price of Desktop: "))
print("Current Rating of Desktop is: ",df.loc[a,"Rating"])
df.loc[a,"Rating"] = int(input("Enter New Rating of Desktop: "))
print("Current Stock of Desktop is: ",df.loc[a,"Stock"])
df.loc[a,"Stock"] = float(input("Enter Updated Stock of Laptop:
"))
print("Current Number of Units Sold is: ",df.loc[a,"Units Sold"])
df.loc[a,"Units Sold"] = input("Enter Updated number of Desktop
Units Sold: ")
print("Current Number of Units Booked is: ",df.loc[a,"Units
Booked"])
df.loc[a,"Units Booked"] = input("Enter Updated number of Desktop
Units Booked: ")

df=pd.to_csv(path_or_buf="D:\Desktop 2.csv",sep=",")
print()
print(df)
print()
print("Desktop Details Updated...")
else:
print('Enter Valid Choice...')
elif ch=='10':
while True:
print()
print('Search A Specific Record... ')
print('Press 1 Search Laptop by ID...')
print('Press 2 Search Desktop by ID...')
print('Press 3 Exit To Main Menu...')

op = int(input('Choose Your Desired Option: '))

if op==1:
df=pd.read_csv("D:\Laptop 1.csv",sep=",",header=0)
a = df.loc[df['ID'] == int(input('Enter ID of the Laptop you
want to search :'))]
print(a)

elif op==2:
df=pd.to_csv(path_or_buf="D:\Desktop 2.csv",sep=",")
a = df.loc[df['ID'] == int(input('Enter ID of the Desktop you
want to search :'))]
print(a)
else:
break

elif ch=='11':
print('Arrange The Data of CSV File...')
print('Press 1 To Arrange Laptop CSV Data File...')
print('Press 2 To Arrange Desktop CSV Data File...')

ch=int(input('Enter your CSV choice: '))


if ch==1:
df=pd.read_csv("D:\Laptop 1.csv",sep=",",header=0)

print('Press 1 To Arrange The Laptop Data As Per Name...')


print('Press 2 To Arrange The Laptop Data As Per Stock...')
print('Press 3 To Arrange The Laptop Data As Per Price...')
print('Press 4 To Arrange The Laptop Data As Per Rating ...')
print('Press 5 to Arrange The Laptop Data As Per Units Booked')
print('Press 6 To Arrange The Laptop Data As Per Units Sold')

op = int(input('Choose Your Desired Option: '))


if op==1:
df1=df.sort_values(['Laptop Name'])
print()
print(df1)
elif op==2:
dfl = df.sort_values(['Stock'])
print()
print(dfl)
elif op==3:
df1 = df.sort_values(['Price'])
print()
print(dfl)
elif op==4:
dfl = df.sort_values(['Ratings'])
print()
print(dfl)
elif op==5:
dfl = df.sort_values(['Units Booked'])
print()
print(dfl)
elif op==6:
dfl = df.sort_values(['Units Sold'])
print()
print(dfl)
else:
print('Enter Valid Choice...')
elif ch==2:
df=pd.read_csv("D:\Desktop 2.csv",sep=",",header=0)
print('Press 1 To Arrange The Desktop Data As Per Name...')
print('Press 2 To Arrange The Desktop Data As Per Stock...')
print('Press 3 To Arrange The Desktop Data As Per Price...')
print('Press 4 To Arrange The Desktop Data As Per Rating ...')
print('Press 5 to Arrange The Desktop Data As Per Units Booked')
print('Press 6 To Arrange The Desktop Data As Per Units Sold')

op = int(input('Choose Your Desired Option: '))

if op==1:
df1 = df.sort_values(['Desktop Model'])
print()
print(df1)
elif op==2:
df1 = df.sort_values(['Stock'])
print()
print(df1)
elif op==3:
df1 = df.sort_values(['Price'])
print()
print(df1)
elif op==4:
df1 = df.sort_values(['Ratings'])
print()
print(df1)
elif op==5:
df1 = df.sort_values(['Units Booked'])
print()
print(df1)
elif op==6:
df1 = df.sort_values(['Units Sold'])
print()
print(df1)
else:
print('Enter Valid Choice...')
else:
print('Enter Valid Choice...')

elif ch=='12':
df1=pd.read_csv("D:\Laptop 1.csv",sep=",",header=0)
df2=pd.read_csv("D:\Desktop 2.csv",sep=",",header=0)

t = int(input('How Many Records To Display From Top: '))


b = int(input('How Many Records To Display From Bottom: '))

print('First ',t,' Records...')


print()
print(df1.head(t))
print()
print(df2.head(t))
print("\nLast ',b,' Records...")
print()
print(df1.tail(b))
print()
print(df2.tail(b))
print()

elif ch=='13':
exit()

else:
print('\n*** Enter a Valid Choice ***')

You might also like