Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # IMPORTING PACKAGES
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- import matplotlib.dates as mdates
- import datetime
- customer_feedback_tuples = []
- customer_feedback_def = [('bill-id', 'i4'),
- ('date', 'M8[us]'),
- ('ambience', 'i4'),
- ('service', 'i4'),
- ('food', 'i4'),
- ('hygiene', 'i4')]
- # CREATING FOR LOOP TO TAKE INPUT FROM CUSTOMERS
- menu_exit = False
- while not menu_exit:
- print('-' * 100)
- print("* Welcome to Cloud Akali! *")
- print("please follow the instructions below to complete the customer survey and rate out of 10! ")
- bill_id = int(input("Enter bill id: "))
- visit_date = datetime.datetime.strptime(
- input('Enter date of visit (dd/mm/yyyy): '),
- '%d/%m/%Y'
- )
- ambience_rating = int(input('How did you like the overall ambience of the restaurant?: '))
- service_rating = int(input("How would you rate our service?: "))
- food_rating = int(input("What did you think about our food?: "))
- hygiene_rating = int(input('Did our restaurant meet your standard of cleanliness and hygiene?: '))
- customer_feedback_tuples.append((bill_id,
- visit_date,
- ambience_rating,
- service_rating,
- food_rating,
- hygiene_rating))
- menu_exit = input('Type "yes" to proceed: ').lower() != 'yes'
- print('-' * 100)
- # example_data = [(1, '2017-01-01', 2, 4, 3, 3), (11, '2018-04-14', 10, 8, 6, 6), (21, '2015-03-30', 4, 7, 7, 8), (31, '2015-12-24', 9, 9, 7, 3), (41, '2020-04-13', 5, 1, 2, 8), (51, '2015-03-29', 3, 5, 10, 9), (61, '2016-05-28', 9, 7, 7, 7), (71, '2018-02-05', 4, 4, 3, 2), (81, '2015-05-02', 7, 9, 7, 6), (91, '2014-05-26', 10, 4, 3, 6), (101, '2019-07-02', 4, 7, 1, 4), (111, '2016-01-01', 6, 10, 9, 3), (121, '2019-02-10', 2, 4, 8, 5), (131, '2017-04-13', 7, 1, 10, 9), (141, '2018-09-01', 3, 4, 5, 8), (151, '2020-02-13', 10, 4, 3, 6), (161, '2017-02-05', 8, 8, 2, 7), (171, '2016-02-17', 1, 9, 9, 2), (181, '2020-06-06', 9, 6, 8, 5), (191, '2017-11-23', 3, 3, 2, 1), (201, '2019-01-03', 7, 1, 2, 3), (211, '2020-07-12', 6, 5, 8, 1), (221, '2015-10-05', 10, 10, 2, 3), (231, '2020-07-01', 3, 1, 3, 4)]
- # customer_feedback_tuples = example_data
- customer_feedback = np.array(customer_feedback_tuples, dtype=customer_feedback_def)
- customer_feedback = np.sort(customer_feedback, order='date') # sorting by date
- df = pd.DataFrame(customer_feedback).set_index('bill-id')
- df.to_csv('csvCA.csv')
- print(df)
- years = mdates.YearLocator() # every year
- months = mdates.MonthLocator() # every month
- years_fmt = mdates.DateFormatter('%Y')
- fig, ax = plt.subplots()
- ax.plot('date', 'ambience', color='red', data=customer_feedback, label='Ambience')
- ax.plot('date', 'service', color='blue', data=customer_feedback, label='Service')
- ax.plot('date', 'food', color='yellow', data=customer_feedback, label='Food')
- ax.plot('date', 'hygiene', color='green', data=customer_feedback, label='Hygiene')
- ax.xaxis.set_major_locator(years)
- ax.xaxis.set_major_formatter(years_fmt)
- ax.xaxis.set_minor_locator(months)
- datemin = np.datetime64(customer_feedback['date'][0], 'Y')
- datemax = np.datetime64(customer_feedback['date'][-1], 'Y') + np.timedelta64(1, 'Y')
- ax.set_xlim(datemin, datemax)
- ax.format_xdata = mdates.DateFormatter('%Y-%m-%d')
- ax.grid(True)
- plt.ylim(0, 10)
- fig.autofmt_xdate()
- plt.xlabel('Year')
- plt.ylabel('Score')
- plt.legend()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement