import pandas as pd
print('Libraries installed')
URL = 'https://raw.githubusercontent.com/nestoredduardo/data-analysis-production/main/production-data.xlsx'
df = pd.read_excel(URL)
df
df = df[(df != 0).all(1)]
kg_lbs = 2.2046
df.insert(7,"Waste Lbs", df['Waste Kg']*kg_lbs)
df.insert(8,'Accumulated Waste Lbs', df['Waste Lbs'].cumsum())
df.head()
df.insert(9,'Effectiveness', df['Accumulated Real Production'] / df['Accumulated Scheduled Production'] *100)
df.insert(10,'Efficiency', df['Accumulated Real Production'] / df['Weekly Capacity'] * 100)
df.insert(11,'Usability', (df['Accumulated Real Production'] + df['Accumulated Waste Lbs'])/df['Weekly Capacity'] *100)
df.insert(12,'Waste %', df['Accumulated Waste Lbs'] / df['Accumulated Scheduled Production'] *100)
df.head()
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
plt.title('Real Production VS Scheduled Production')
ax.plot(df.index, df['Real Production'], label='Real Production')
ax.fill_between(df.index,0,df['Real Production'])
ax.plot(df.index, df['Scheduled Production'], label='Scheduled Production', linewidth=4)
fig.set_figheight(6)
fig.set_figwidth(12)
leg= ax.legend()
fig, ax = plt.subplots()
plt.title('Cumulative production tracking')
ax.plot(df.index, df['Accumulated Real Production'], label='Accumulated Real Production',marker='o')
ax.plot(df.index, df['Accumulated Scheduled Production'], label='Accumulated Scheduled Production', marker='o')
ax.plot(df.index, df['Weekly Capacity'], label='Accumulative Weekly Capacity', color='r', linewidth=4)
fig.set_figheight(6)
fig.set_figwidth(14)
plt.xticks(np.arange(min(df.index), max(df.index)+1, 1.0))
leg= ax.legend()
fig, ax = plt.subplots()
plt.title('Production and Waste')
ax.plot(df.index, df['Accumulated Real Production'], label='Accumulated Real Production',linewidth=4)
ax.plot(df.index, df['Accumulated Waste Lbs'], label='Accumulated Waste Lbs',linewidth=4)
plt.xticks(np.arange(min(df.index), max(df.index)+1, 1.0))
fig.set_figheight(6)
fig.set_figwidth(14)
leg = ax.legend()
fig, ax = plt.subplots()
plt.title('Efficiency, Effectiveness and Usability ')
ax.plot(df.index, df['Efficiency'], label='Efficiency',linewidth=4)
ax.plot(df.index, df['Effectiveness'], label='Effectiveness',linewidth=4)
ax.plot(df.index, df['Usability'], label='Usability', linewidth=4)
fig.set_figheight(6)
fig.set_figwidth(14)
leg = ax.legend()
efficiency = df['Efficiency'].iloc[-1]
effectiveness = df['Effectiveness'].iloc[-1]
usability = df['Usability'].iloc[-1]
print("Efficiency %: {}".format(efficiency))
print("Effectiveness %: {}".format(effectiveness))
print("Usability %: {}".format(usability))
waste = df['Waste %'].iloc[-1]
print("Total waste %: {}".format(waste))