This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Plot x-bar control chart | |
| # Line chart | |
| line_plot = df_grouped.hvplot.line( | |
| x='sample_group', | |
| y=['x_bar','UCL','+2s','+1s','x_bar_bar','-1s','-2s','LCL'], | |
| xlabel="Sample Group", | |
| title="x-bar chart", | |
| height=500, | |
| width=1000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get control limits | |
| df_grouped['x_bar_bar'] = statistics.mean(df_grouped['x_bar']) | |
| df_grouped['UCL'] = statistics.mean(df_grouped['x_bar'])+(0.577*statistics.mean(df_grouped['R'])) | |
| df_grouped['+2s'] = (df_grouped['UCL']-df_grouped['x_bar_bar'])/3*2+df_grouped['x_bar_bar'] | |
| df_grouped['+1s'] = (df_grouped['UCL']-df_grouped['x_bar_bar'])/3*1+df_grouped['x_bar_bar'] | |
| df_grouped['-1s'] = df_grouped['x_bar_bar']-(df_grouped['UCL']-df_grouped['x_bar_bar'])/3*1 | |
| df_grouped['-2s'] = df_grouped['x_bar_bar']- (df_grouped['UCL']-df_grouped['x_bar_bar'])/3*2 | |
| df_grouped['LCL'] = statistics.mean(df_grouped['x_bar'])-(0.577*statistics.mean(df_grouped['R'])) | |
| df_grouped.head() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Add R (range) column | |
| df_max = df.groupby('sample_group').max() | |
| df_min = df.groupby('sample_group').min() | |
| df_grouped['R'] = df_max['data'] - df_min['data'] | |
| df_grouped.head() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Group masures by sample groups (x_bar) | |
| df_grouped = df.groupby('sample_group').mean() | |
| # Rename x-bar column | |
| df_grouped.columns = ['x_bar'] | |
| df_grouped.head() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import required libraries | |
| import numpy as np | |
| import pandas as pd | |
| import statistics | |
| import hvplot | |
| import hvplot.pandas | |
| # Set a random seed | |
| np.random.seed(42) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Initialize lists where we will store the information for future analysis | |
| customer_number_list = [] | |
| time_arrived_to_system_list = [] | |
| time_arrived_to_queue_list = [] | |
| time_start_order_placing_list =[] | |
| time_end_order_placing_list = [] | |
| time_order_delivered_list = [] | |
| time_exit_system_list = [] | |
| total_time_placing_order_list = [] | |
| total_time_waiting_for_order = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import required libraries | |
| import time | |
| import datetime | |
| import numpy as np | |
| import pandas as pd | |
| # Define the customer class (i.e., the agent) | |
| class customer: | |
| def __init__(self): | |
| self.customer_number = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import required libraries | |
| from wordcloud import WordCloud | |
| import matplotlib.pyplot as plt | |
| plt.style.use('seaborn-whitegrid') | |
| import matplotlib as mpl | |
| # Set wordcloud size | |
| mpl.rcParams['figure.figsize'] = [20.0, 10.0] | |
| # Define a wordcloud function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import required libraries | |
| from nltk.tokenize import word_tokenize | |
| from nltk.corpus import stopwords | |
| from string import punctuation | |
| # Download list of stopwords | |
| stop = stopwords.words('english') | |
| # Create a list of additional stopwords | |
| additional_stopwords = ["strong", "markup", "h3", "em", "class="] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Declare a function to remove '\xa0' from stores titles | |
| def string_cleaning(text): | |
| correct_title = text.replace(u'\xa0', u' ') | |
| return correct_title | |
| # Apply function to stories titles | |
| df["title"] = df.title.apply(string_cleaning) |