Advertisement
nein_yards

Untitled

Feb 28th, 2021
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. import numpy as np
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4. import matplotlib.dates as mdates
  5. import datetime
  6.  
  7. customer_feedback_tuples = []
  8. customer_feedback_def = [('bill-id', 'i4'),
  9. ('visit-date', 'M8[us]'),
  10. ('ambience', 'i4'),
  11. ('service', 'i4'),
  12. ('food', 'i4'),
  13. ('hygiene', 'i4')]
  14.  
  15. while not menu_exit:
  16. print("* Welcome to Cloud Akali! *")
  17. bill_id = int(input("Enter bill id: "))
  18. visit_date = datetime.datetime.strptime(input('Enter date of visit (dd/mm/yyyy): '), '%d/%m/%Y')
  19. print('Rate your experience for each of the below from 1-10')
  20.  
  21. ambience_rating = int(input('\tAmbience: '))
  22. service_rating = int(input("\tService: "))
  23. food_rating = int(input("\tFood: "))
  24. hygiene_rating = int(input('\tHygiene: '))
  25. customer_feedback_tuples.append((bill_id,
  26. visit_date,
  27. ambience_rating,
  28. service_rating,
  29. food_rating,
  30. hygiene_rating))
  31. menu_exit = input('Type "yes" to proceed: ').lower() != 'yes'
  32. print('=' * 100)
  33.  
  34. customer_feedback = np.array(customer_feedback_tuples, dtype=customer_feedback_def)
  35. customer_feedback = np.sort(customer_feedback, order='visit-date')
  36.  
  37. df = pd.DataFrame(customer_feedback).set_index('bill-id')
  38. df.to_csv('csvCA.csv')
  39. print(df)
  40.  
  41. fig, ax = plt.subplots()
  42.  
  43. ax.plot('visit-date', 'ambience', data=customer_feedback, label='Ambience')
  44. ax.plot('visit-date', 'service', data=customer_feedback, label='Service')
  45. ax.plot('visit-date', 'hygiene', data=customer_feedback, label='Hygiene')
  46. ax.plot('visit-date', 'food', data=customer_feedback, label='Food')
  47.  
  48. ax.xaxis.set_major_locator(mdates.YearLocator())
  49. ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
  50. ax.xaxis.set_minor_locator(mdates.MonthLocator())
  51.  
  52. date_min = np.datetime64(customer_feedback['visit-date'][0], 'Y')
  53. date_max = np.datetime64(customer_feedback['visit-date'][-1], 'Y') + np.timedelta64(1, 'Y')
  54. ax.set_xlim(date_min, date_max)
  55. plt.ylim(0, 10)
  56.  
  57. ax.format_xdata = mdates.DateFormatter('%Y-%m-%d')
  58. ax.grid(True)
  59.  
  60. fig.autofmt_xdate()
  61. plt.xlabel('Year')
  62. plt.ylabel('Score')
  63.  
  64. plt.legend()
  65. plt.show()
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement