Update work/tbx/charter/meraki_info.md
This commit is contained in:
@@ -1,3 +1,102 @@
|
||||
To use Jupyter Notebook for displaying the calculations and visualizations, you can refactor the code into separate cells within a notebook. Here's how you can organize the code in a Jupyter Notebook:
|
||||
|
||||
```python
|
||||
# Cell 1: Import necessary libraries
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
import seaborn as sns
|
||||
|
||||
# Cell 2: Load the inventory data from a CSV file
|
||||
data = pd.read_csv("raw_data.csv")
|
||||
|
||||
# Cell 3: Create a summary table for slow-moving inventory
|
||||
slow_moving = data[(data['Qty on hand'] > 0) & (data['12mo Iss Qty'] == 0)]
|
||||
slow_moving_table = slow_moving[['Material', 'Material description', 'Qty on hand', 'Value on hand']]
|
||||
print("Slow-Moving Inventory:")
|
||||
display(slow_moving_table)
|
||||
|
||||
# Cell 4: Create a summary table for fast-moving inventory
|
||||
fast_moving = data[(data['Qty on hand'] > 0) & (data['12mo Iss Qty'] > 1000)]
|
||||
fast_moving_table = fast_moving[['Material', 'Material description', 'Qty on hand', '12mo Iss Qty', '12mo Iss Val']]
|
||||
print("Fast-Moving Inventory:")
|
||||
display(fast_moving_table)
|
||||
|
||||
# Cell 5: Create a summary table for potential excess inventory
|
||||
excess_inventory = data[(data['Qty on hand'] > 500) & (data['YTD Issuance Qty'] < data['Qty on hand'] * 0.5)]
|
||||
excess_inventory_table = excess_inventory[['Material', 'Material description', 'Qty on hand', 'YTD Issuance Qty']]
|
||||
print("Potential Excess Inventory:")
|
||||
display(excess_inventory_table)
|
||||
|
||||
# Cell 6: Perform ABC classification
|
||||
data['ABC_Class'] = pd.qcut(data['12mo Iss Val'], q=[0, 0.7, 0.9, 1.0], labels=['A', 'B', 'C'])
|
||||
abc_summary = data.groupby('ABC_Class').agg({'12mo Iss Val': 'sum', 'Material': 'count'}).reset_index()
|
||||
abc_summary.columns = ['ABC_Class', 'Issuance Value', 'Item Count']
|
||||
print("ABC Classification Summary:")
|
||||
display(abc_summary)
|
||||
|
||||
# Cell 7: Create a pie chart for ABC classification
|
||||
plt.figure(figsize=(8, 6))
|
||||
plt.pie(abc_summary['Issuance Value'], labels=abc_summary['ABC_Class'], autopct='%1.1f%%')
|
||||
plt.title('ABC Classification by Issuance Value')
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
|
||||
# Cell 8: Create a bar chart for inventory turnover ratio
|
||||
data['Inventory Turnover Ratio'] = data['12mo Iss Val'] / data['Value on hand']
|
||||
inventory_turnover = data.groupby('Material')['Inventory Turnover Ratio'].mean()
|
||||
plt.figure(figsize=(12, 6))
|
||||
plt.bar(inventory_turnover.index, inventory_turnover.values)
|
||||
plt.xlabel('Material')
|
||||
plt.ylabel('Inventory Turnover Ratio')
|
||||
plt.title('Inventory Turnover Ratio by Material')
|
||||
plt.xticks(rotation=45)
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
|
||||
# Cell 9: Create a histogram for days of supply
|
||||
days_of_supply = data['Qty on hand'] / (data['12mo Iss Qty'] / 365)
|
||||
plt.figure(figsize=(8, 6))
|
||||
sns.histplot(days_of_supply, bins=20, kde=True)
|
||||
plt.xlabel('Days of Supply')
|
||||
plt.ylabel('Frequency')
|
||||
plt.title('Distribution of Days of Supply')
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
|
||||
# Cell 10: Calculate and print KPIs
|
||||
total_inventory_value = data['Value on hand'].sum()
|
||||
total_issuance_value = data['12mo Iss Val'].sum()
|
||||
|
||||
inventory_turnover_ratio = total_issuance_value / total_inventory_value
|
||||
days_of_supply_avg = data['Qty on hand'].sum() / (data['12mo Iss Qty'].sum() / 365)
|
||||
stock_availability_percentage = (data[data['Qty on hand'] > 0].shape[0] / data.shape[0]) * 100
|
||||
|
||||
print("Key Performance Indicators (KPIs):")
|
||||
print(f"Inventory Turnover Ratio: {inventory_turnover_ratio:.2f}")
|
||||
print(f"Days of Supply (Average): {days_of_supply_avg:.2f}")
|
||||
print(f"Stock Availability Percentage: {stock_availability_percentage:.2f}%")
|
||||
```
|
||||
|
||||
In this refactored code:
|
||||
|
||||
- The code is divided into separate cells for better organization and readability.
|
||||
- The `display()` function is used instead of `print()` to display the summary tables in a more visually appealing way within the notebook.
|
||||
- The `plt.show()` function is used to display the plots directly in the notebook.
|
||||
- The warnings related to `FigureCanvasAgg` being non-interactive should not appear in the notebook environment.
|
||||
|
||||
To run this code in a Jupyter Notebook:
|
||||
|
||||
1. Open a new notebook in Jupyter.
|
||||
2. Copy and paste each cell into separate cells in the notebook.
|
||||
3. Make sure the `raw_data.csv` file is in the same directory as the notebook or provide the correct file path.
|
||||
4. Run each cell in order by pressing Shift+Enter or using the "Run" button in the toolbar.
|
||||
|
||||
The results, including the summary tables, visualizations, and KPIs, will be displayed inline in the notebook cells.
|
||||
|
||||
Remember to adjust the file path for the `raw_data.csv` file if needed, and ensure that you have the necessary libraries (pandas, matplotlib, seaborn) installed in your Jupyter Notebook environment.
|
||||
|
||||
---
|
||||
|
||||
Here is the complete inventory analysis report for the Meraki MX and MS product lines, incorporating all the information provided:
|
||||
|
||||
```markdown
|
||||
|
||||
Reference in New Issue
Block a user