Share & Revise Any Time

Related Posts


List of All Python / MySQL / CSV Projects


Learn Python Programming


This project is made using python and csv.

  • Use the address of csv saved in your pc i.e given in the third line of this project

import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv(r'C:\Users\P0YHtg\D\HotelsOfIndia.csv')

def graph1():
  Year=df["Year"]
  Hotel=df["One Star - Hotels"]
  plt.plot(Year,Hotel)
  plt.xlabel("Year")
  plt.ylabel("No. of hotels in india")
  plt.xticks(Year, rotation='vertical')
  plt.title("comparison of number of one star hotels year wise in india")
  plt.show()
  
def graph2():
  Year=df["Year"]
  Hotel=df["Two Star - Hotels"]
  plt.plot(Year,Hotel)
  plt.xlabel("Year")
  plt.ylabel("No. of hotels in india")
  plt.xticks(Year, rotation='vertical')
  plt.title("comparison of number of two star hotels year wise in india")
  plt.show()

def graph3():
  Year=df["Year"]
  Hotel=df["Three Star - Hotels"]
  plt.plot(Year,Hotel)
  plt.xlabel("Year")
  plt.ylabel("No. of hotels in india")
  plt.xticks(Year, rotation='vertical')
  plt.title("comparison of number of three star hotels year wise in india")
  plt.show()

def graph4():
  Year=df["Year"]
  Hotel=df["Four Star - Hotels"]
  plt.plot(Year,Hotel)
  plt.xlabel("Year")
  plt.ylabel("No. of hotels in india")
  plt.xticks(Year, rotation='vertical')
  plt.title("comparison of number of four star hotels year wise in india")
  plt.show()

def graph5():
  Year=df["Year"]
  Hotel=df["Five Star - Hotels"]
  plt.plot(Year,Hotel)
  plt.xlabel("Year")
  plt.ylabel("No. of hotels in india")
  plt.xticks(Year, rotation='vertical')
  plt.title("comparison of number of five star hotels year wise in india")
  plt.show()

def graph6():
  Year=df["Year"]
  GrTotalHotel=df["Grand Total - Hotels"]
  plt.bar(Year,GrTotalHotel, color='maroon', width=0.4  )
  plt.xlabel("Year")
  plt.ylabel("Grandtotal of hotels in India")
  plt.xticks(Year, rotation='vertical' )
  plt.title("Comparison of grandtotal of no. of hotels year wise in india")
  plt.show()

def graph7():
  x=df["Year"]
  x1=x-0.2
  x2=x  
  Marks1=df["Grand Total - Hotels"] 
  Marks2=df["One Star - Hotels"] 
  plt.xlabel("Number of Hotels in India")
  plt.ylabel("Years")
  plt.title("Yearwise comparison between grandtotal hotels and one star hotels")
  plt.bar(x1,Marks1,width=0.4,color='g',align='center')
  plt.bar(x2,Marks2,width=0.4,color='Red',align='center')
  plt.legend(["GrandTotal","One Star"])
  plt.show()

def graph8():
  x=df["Year"]
  x1=x-0.2
  x2=x  
  Marks1=df["Grand Total - Hotels"] 
  Marks2=df["Two Star - Hotels"] 
  plt.xlabel("Number of Hotels in India")
  plt.ylabel("Years")
  plt.title("Yearwise comparison between grandtotal hotels and two star hotels")
  plt.bar(x1,Marks1,width=0.4,color='g',align='center')
  plt.bar(x2,Marks2,width=0.4,color='Red',align='center')
  plt.legend(["GrandTotal","Two Star"])
  plt.show()

def graph9():
  x=df["Year"]
  x1=x-0.2
  x2=x  
  Marks1=df["Grand Total - Hotels"] 
  Marks2=df["Three Star - Hotels"] 
  plt.xlabel("Number of Hotels in India")
  plt.ylabel("Years")
  plt.title("Yearwise comparison between grandtotal hotels and three star hotels")
  plt.bar(x1,Marks1,width=0.4,color='g',align='center')
  plt.bar(x2,Marks2,width=0.4,color='Red',align='center')
  plt.legend(["GrandTotal","Three Star"])
  plt.show()

def graph10():
  x=df["Year"]
  x1=x-0.2
  x2=x  
  Marks1=df["Grand Total - Hotels"] 
  Marks2=df["Four Star - Hotels"] 
  plt.xlabel("Number of Hotels in India")
  plt.ylabel("Years")
  plt.title("Yearwise comparison between grandtotal hotels and four star hotels")
  plt.bar(x1,Marks1,width=0.4,color='g',align='center')
  plt.bar(x2,Marks2,width=0.4,color='Red',align='center')
  plt.legend(["GrandTotal","Four Star"])
  plt.show()

def graph11():
  x=df["Year"]
  x1=x-0.2
  x2=x  
  Marks1=df["Grand Total - Hotels"] 
  Marks2=df["Five Star - Hotels"] 
  plt.xlabel("Number of Hotels in India")
  plt.ylabel("Years")
  plt.title("Yearwise comparison between grandtotal hotels and five star hotels")
  plt.bar(x1,Marks1,width=0.4,color='g',align='center')
  plt.bar(x2,Marks2,width=0.4,color='Red',align='center')
  plt.legend(["GrandTotal","Five Star"])
  plt.show()
  
while True:
  print("   1. one star hotels")
  print("   2. two star hotels")
  print("   3. three star hotels")
  print("   4. four star hotels")
  print("   5. five star hotels")
  print("   6. grandtotal of number of hotels")
  print("   7. number of hotels and one star hotels")
  print("   8. number of hotels and two star hotels")
  print("   9. number of hotels and three star hotels")
  print("   10. grandtotal of number of hotels and four star hotels")
  print("   11. grandtotal of number of hotels and five star hotels")
  print("   12. Exit")
  print()
  choice=int(input("  Enter your choice : "))
  if choice==1:
    graph1()
  elif choice==2:
    graph2()  
  elif choice==3:
    graph3()
  elif choice==4:
    graph4()    
  elif choice==5:
    graph5()  
  elif choice==6:
    graph6()
  elif choice==7:
    graph7()
  elif choice==8:
    graph8()
  elif choice==9:
    graph9()
  elif choice==10:
    graph10()
  elif choice==11:
    graph11()
  elif choice==12:
    break  
  else:
    print("Enter correct choice")
    



Share & Revise Any Time