0% found this document useful (0 votes)
35 views6 pages

Harshil Concert Management

This Python program uses Pandas to manage a CSV file containing concert data. It defines functions to add, display, delete, update records and perform data analysis. The functions allow the user to interactively input/select criteria to retrieve, modify and analyze records by concert name, artist, date or venue. Data analysis generates bar plots of net income by date. The main loop displays a menu for the user to choose these options until exiting.

Uploaded by

nishi25wadhwani
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)
35 views6 pages

Harshil Concert Management

This Python program uses Pandas to manage a CSV file containing concert data. It defines functions to add, display, delete, update records and perform data analysis. The functions allow the user to interactively input/select criteria to retrieve, modify and analyze records by concert name, artist, date or venue. Data analysis generates bar plots of net income by date. The main loop displays a menu for the user to choose these options until exiting.

Uploaded by

nishi25wadhwani
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/ 6

In [2]:

import matplotlib.pyplot as plt


import pandas as pd

path = '/Users/JayNaik/xii2024/concert.csv'

def AddDetails():
concert = pd.read_csv(path,names=['ConcertName','Artist', 'Date', 'Venu
L = list()
D = {}
while True:
venue =input('Enter Name of the venue in capital letters::')
date =input('Enter Date in the format of DD-MM-YYYY::')
artist = input('Enter Name of Artist in capital letters::')
concert.index = concert.Date
if date in concert.index:
concert.index = concert.Venue
if venue in concert.index:
print('Concert on entered venue already exists on that date
else:
concert.index = concert.Artist
if artist in concert.index:
print('Concert of the entered artist already exists on
else:
break
else:
break
D['ConcertName'] = input('Enter Name of the concert in capital letters:
D['Artist'] = artist
D['Date'] = date
D['Venue'] = venue
D['TicketsSold'] = int(input('Enter Number of Tickets Sold::'))
D['TicketPrice'] = int(input('Enter the price of 1 ticket::'))
D['Expenses'] = int(input('Enter extra expense of the concert::'))
L.append(D)
df = pd.DataFrame(L)
df.to_csv(path,index = False,mode = 'a',header = False)
print('RECORD ADDED SUCCESSFULLY...')

def DisplayDetails():
df = pd.read_csv(path,names=['ConcertName','Artist','Date','Venue','Tic
print('1 - All Records')
print('2 - Records according to Artist')
print('3 - Records according to Date')
print('4 - Records according to Concert Name')
print('5 - Records according to Venue')
c = int(input('Enter choice::'))
if c == 1:
print(df)
elif c == 2:
artist = input('Enter name of artist to be displayed in capital let
df.index = df.Artist
if artist in df.index:
print('Artist found...')
print(df.loc[artist])
else:
print('Artist not found...')
elif c == 3:
date = input('Enter date to be displayed in format DD-MM-YYYY')
df.index = df.Date
if date in df.index:
print('Date found...')
print(df.loc[date])
else:
print('Date not found...')
elif c == 4:
name = input('Enter name of the concert to be displayed in capital
df.index = df.ConcertName
if name in df.index:
print('Concert name found...')
print(df.loc[name])
else:
print('Concert Name not found...')
elif c == 5:
venue = input('Enter name of the venue to be displayed in capital l
df.index = df.Venue
if venue in df.index:
print('Venue found...')
print(df.loc[venue])
else:
print('Venue not found...')
else:
print('Invalid choice entered...')

def DeleteRecord():
df = pd.read_csv(path,names=['ConcertName','Artist','Date','Venue','Tic
print('1 - Delete Record according to Concert name')
print('2 - Delete Record according to artist')
print('3 - Delete Record according to Date')
print('4 - Delete Record according to Venue')
c = int(input('Enter choice::'))
if c == 1:
name = input('Enter name of the concert to be deleted in capital le
df.index = df.ConcertName
if name in df.index:
print('Concert name found...')
df = df.drop([name])
df.to_csv(path,index = False,header = False)
print('Record Deleted Successfully')
else:
print('Concert Name not found')
elif c == 2:
artist = input('Enter name of the artist to be deleted in capital l
df.index = df.Artist
if artist in df.index:
print('Artist name found...')
df = df.drop([artist])
df.to_csv(path,index = False,header = False)
print('Record Deleted Successfully')
else:
print('Artist not found')
elif c == 3:
date = input('Enter date to be deleted in format DD-MM-YYYY:')
df.index = df.Date
if date in df.index:
print('Date found...')
df = df.drop([date])
df.to_csv(path,index = False,header = False)
print('Record Deleted Successfully')
else:
print('Date not found')
elif c == 4:
venue = input('Enter venue of the concert to be deleted in capital
df.index = df.Venue
if venue in df.index:
print('Venue found...')
df = df.drop([venue])
df.to_csv(path,index = False,header = False)
print('Record Deleted Successfully')
else:
print('Venue not found')
else:
print('Invalid choice entered...')

def UpdateRecord():
df = pd.read_csv(path,names=['ConcertName','Artist','Date','Venue','Tic
print(df)
index = int(input('Enter Index of row to be changed'))
if index in df.index:
print('ConcertName::',df.loc[index,'ConcertName'])
c = input('Do you want to change this? Y/N')
if c == 'Y' or c == 'y':
df.loc[index,'ConcertName'] = input('Enter new ConcertName in c
print('Venue::',df.loc[index,'Venue'])
c = input('Do you want to change this? Y/N')
if c == 'Y' or c == 'y':
df.loc[index,'Venue'] = input('Enter new Venue in capital lette
print('TicketsSold::',df.loc[index,'TicketsSold'])
c = input('Do you want to change this? Y/N')
if c == 'Y' or c == 'y':
df.loc[index,'TicketsSold'] = int(input('Enter new data of Tick
print('TicketPrice::',df.loc[index,'TicketPrice'])
c = input('Do you want to change this? Y/N')
if c == 'Y' or c == 'y':
df.loc[index,'TicketPrice'] = int(input('Enter new data of Tick
print('Expenses::',df.loc[index,'Expenses'])
c = input('Do you want to change this? Y/N')
if c == 'Y' or c == 'y':
df.loc[index,'Expenses'] = int(input('Enter new data of Expense
df.to_csv(path,index = False,header = False)
print('Record Updated Successfully')
else:
print('Index not found')

def DataAnalysis():
df = pd.read_csv(path,names=['ConcertName','Artist','Date','Venue','Tic
print('1 - Analysis according to concert name')
print('2 - Analysis according to artist')
print('3 - Anaylsis according to Venue')
c = int(input('Enter choice::'))
if c == 1:
df.index = df.ConcertName
concert = input('Enter Concert Name in capital letters::')
if concert in df.index:
temp = pd.read_csv(path,names=['ConcertName','Artist','Date','V
temp = temp[temp['ConcertName'] == concert]
temp['Revenue'] = temp.TicketsSold * temp.TicketPrice
temp['NetIncome'] = temp.Revenue - temp.Expenses
plt.bar(temp.Date,temp.NetIncome,color =['Red','blue','green','
plt.title('--------Net Income-------',fontsize = 30,color = 'bl
plt.xlabel('-------Date--------',fontsize = 20,color = 'red')
plt.ylabel('-------NetIncome--------',fontsize = 20,color = 're
plt.xticks(temp.Date,fontsize = 15,color = 'g',rotation = 45)
plt.yticks(temp.NetIncome,fontsize = 10,color = 'g',rotation =
plt.grid(True)
plt.figure(figsize = (5,4))
plt.show()
elif c == 2:
df.index = df.Artist
artist = input('Enter name of the artist in capital letters::')
if artist in df.index:
temp = pd.read_csv(path,names=['ConcertName','Artist','Date','V
temp = temp[temp['Artist'] == artist]
temp['Revenue'] = temp.TicketsSold * temp.TicketPrice
temp['NetIncome'] = temp.Revenue - temp.Expenses
plt.bar(temp.Date,temp.NetIncome,color =['Red','blue','green','
plt.title('--------Net Income-------',fontsize = 30,color = 'bl
plt.xlabel('-------Date--------',fontsize = 20,color = 'red')
plt.ylabel('-------NetIncome--------',fontsize = 20,color = 're
plt.xticks(temp.Date,fontsize = 15,color = 'g',rotation = 45)
plt.yticks(temp.NetIncome,fontsize = 10,color = 'g',rotation =
plt.grid(True)
plt.figure(figsize = (5,4))
plt.show()
elif c == 3:
df.index = df.Venue
venue = input('Enter venue in capital letters::')
if venue in df.index:
temp = pd.read_csv(path,names=['ConcertName','Artist','Date','V
temp = temp[temp['Venue'] == venue]
temp['Revenue'] = temp.TicketsSold * temp.TicketPrice
temp['NetIncome'] = temp.Revenue - temp.Expenses
plt.bar(temp.Date,temp.NetIncome,color =['Red','blue','green','
plt.title('--------Net Income-------',fontsize = 30,color = 'bl
plt.xlabel('-------Date--------',fontsize = 20,color = 'red')
plt.ylabel('-------NetIncome--------',fontsize = 20,color = 're
plt.xticks(temp.Date,fontsize = 15,color = 'g',rotation = 45)
plt.yticks(temp.NetIncome,fontsize = 10,color = 'g',rotation =
plt.grid(True)
plt.figure(figsize = (5,4))
plt.show()
else:
print('Invalid choice entered...')

while True:

print('1 - Add Details')


print('2 - Display Details')
print('3 - Delete Record')
print('4 - Update Record')
print('5 - DataAnalysis')
print('6 - Exit')

c = int(input('Enter your choice::'))

if c == 1:
AddDetails()

elif c == 2:
DisplayDetails()

elif c == 3:
DeleteRecord()

elif c == 4:
UpdateRecord()

elif c == 5:
DataAnalysis()
elif c == 6:
break

else:
print('Invalid choice entered...')

1 - Add Details
2 - Display Details
3 - Delete Record
4 - Update Record
5 - DataAnalysis
6 - Exit
Enter your choice::5
1 - Analysis according to concert name
2 - Analysis according to artist
3 - Anaylsis according to Venue
Enter choice::1
Enter Concert Name in capital letters::ERAS TOUR 2023

<Figure size 500x400 with 0 Axes>

1 - Add Details
2 - Display Details
3 - Delete Record
4 - Update Record
5 - DataAnalysis
6 - Exit
Enter your choice::6

In [ ]:

You might also like