Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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'),
- ('visit-date', 'M8[us]'),
- ('ambience', 'i4'),
- ('service', 'i4'),
- ('food', 'i4'),
- ('hygiene', 'i4')]
- while not menu_exit:
- print("* Welcome to Cloud Akali! *")
- bill_id = int(input("Enter bill id: "))
- visit_date = datetime.datetime.strptime(input('Enter date of visit (dd/mm/yyyy): '), '%d/%m/%Y')
- print('Rate your experience for each of the below from 1-10')
- ambience_rating = int(input('\tAmbience: '))
- service_rating = int(input("\tService: "))
- food_rating = int(input("\tFood: "))
- hygiene_rating = int(input('\tHygiene: '))
- 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)
- customer_feedback = np.array(customer_feedback_tuples, dtype=customer_feedback_def)
- customer_feedback = np.sort(customer_feedback, order='visit-date')
- df = pd.DataFrame(customer_feedback).set_index('bill-id')
- df.to_csv('csvCA.csv')
- print(df)
- fig, ax = plt.subplots()
- ax.plot('visit-date', 'ambience', data=customer_feedback, label='Ambience')
- ax.plot('visit-date', 'service', data=customer_feedback, label='Service')
- ax.plot('visit-date', 'hygiene', data=customer_feedback, label='Hygiene')
- ax.plot('visit-date', 'food', data=customer_feedback, label='Food')
- ax.xaxis.set_major_locator(mdates.YearLocator())
- ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
- ax.xaxis.set_minor_locator(mdates.MonthLocator())
- date_min = np.datetime64(customer_feedback['visit-date'][0], 'Y')
- date_max = np.datetime64(customer_feedback['visit-date'][-1], 'Y') + np.timedelta64(1, 'Y')
- ax.set_xlim(date_min, date_max)
- plt.ylim(0, 10)
- ax.format_xdata = mdates.DateFormatter('%Y-%m-%d')
- ax.grid(True)
- fig.autofmt_xdate()
- plt.xlabel('Year')
- plt.ylabel('Score')
- plt.legend()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement