Skip to content

Instantly share code, notes, and snippets.

View samirsaci's full-sized avatar

Samir Saci samirsaci

View GitHub Profile
def create_json(df_nodes, df_links):
''' Create json from dataframes'''
json1 = []
for index, row in df_nodes.reset_index().iterrows():
dico = {}
dico['group'] = int(row['group'])
dico['name'] = row['name']
json1.append(dico)
json2 = []
{
"links": [
{
"source": 0,
"target": 0,
"value": 1947
},
{
"source": 0,
"target": 1,
d3.json("/get-json").then(function(brands) {
var matrix = [],
nodes = brands.nodes,
n = nodes.length;
@samirsaci
samirsaci / email_1.vb
Last active October 23, 2022 12:05
Email Back-Up - Init
Sub SaveMSG_as_HTML()
Application.ScreenUpdating = False
'Initiliaze Parameters
Dim olMsg As MailItem
Dim strPath As String
Dim strMsg As String
Dim strHTML As String
Dim Sender, Received_Time As String
Dim ID As Integer
ID = 1
@samirsaci
samirsaci / email_loop.vb
Last active March 26, 2021 13:58
Email VBA - 2
'Loop through each (.msg) file in your folder strIn
Do While myFile <> ""
'Create record in Excel File
On Error Resume Next
Sheets(1).Cells(ID + 1, 1) = ID
Sheets(1).Cells(ID + 1, 7) = myFile
'Open (.msg) file
Set olMsg = Session.OpenSharedItem(strIn & myFile)
strName = ID & ".html"
Sub SaveMSG_as_HTML()
Application.ScreenUpdating = False
Dim olMsg As MailItem
Dim strPath As String
Dim strMsg As String
Dim strHTML As String
Dim Sender, Received_Time As String
@samirsaci
samirsaci / transactions.csv
Last active March 31, 2021 21:02
Transactions
DATE_FORMAT ORDER_NUMBER SKU BOX
01/01/2017 835220 290731 1.0
01/01/2017 835220 373272 1.0
01/01/2017 835214 362101 1.0
@samirsaci
samirsaci / import.py
Created March 31, 2021 21:05
Import Lib
import pandas as pd
import matplotlib.pyplot as plt
# Import
df = pd.read_excel('In/' + '1-2017.xlsx')
print("{:,} order lines for {:,} orders".format(len(df), df.ORDER_NUMBER.nunique()))
@samirsaci
samirsaci / pareto_process.py
Created March 31, 2021 21:13
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()
@samirsaci
samirsaci / pareto.csv
Last active March 31, 2021 21:24
Pareto CSV
index SKU BOX CumSum %CumSum %SKU
1 359803 4810 4810 2.911658 0.020559
2 290478 4132 8942 5.412898 0.041118
3 366639 4104 13046 7.897190 0.061678
4 359958 4062 17108 10.356058 0.082237
5 253500 3879 20987 12.704149 0.102796