Skip to content

Instantly share code, notes, and snippets.

@samirsaci
Created March 31, 2021 21:13
Show Gist options
  • Select an option

  • Save samirsaci/5c1b456b90fe75a7d6e36815f391c2d9 to your computer and use it in GitHub Desktop.

Select an option

Save samirsaci/5c1b456b90fe75a7d6e36815f391c2d9 to your computer and use it in GitHub Desktop.
Pareto Process
# BOX/SKU
df_par = pd.DataFrame(df.groupby(['SKU'])['BOX'].sum())
df_par.columns = ['BOX']
# Sort Values
df_par.sort_values(['BOX'], ascending = False, inplace = True)
df_par.reset_index(inplace = True)
# Cumulative Sum
df_par['CumSum'] = df_par['BOX'].cumsum()
# % CumSum
df_par['%CumSum'] = (100 * df_par['CumSum']/df_par['BOX'].sum())
# % SKU
df_par['%SKU'] = (100 * (df_par.index + 1).astype(float)/(df_par.index.max() + 1))
print("Pareto Analysis for {:,} unique SKU".format(len(df_par)))
df_par.set_index('SKU').head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment