This file contains 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
def do_kdtree(combined_x_y_arrays, points): | |
mytree = scipy.spatial.cKDTree(combined_x_y_arrays) | |
dist, indexes = mytree.query(points) | |
return indexes | |
def get_grid(x, y, size_x=40, size_y=40): | |
min_x = np.min(x) | |
max_x = np.max(x) | |
min_y = np.min(y) | |
max_y = np.max(y) |
This file contains 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
def get_kncg(df, K=4): | |
# df is a pandas dataframe with mandatory columns ['x','y'] | |
graph = get_knntree(df, 1) | |
for node_a, row in df.iterrows(): | |
if node_a % KK_prints == 0: | |
print(K) | |
node_a_coord = list(row[:2]) | |
ncns = [] |
This file contains 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 networkx as nx | |
from scipy.spatial.distance import euclidean, pdist, squareform | |
import pandas as pd | |
import numpy as np | |
def get_gong(df, y=0): | |
# df is a DataFrame with columns 'x' and 'y' | |
graph = nx.DiGraph() | |
graph.add_nodes_from(df.iterrows()) | |
dists = pdist(df[["x", "y"]]) |
This file contains 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
def stacked_plots(traces, name): | |
fig = tools.make_subplots(rows = len(traces), cols =1) | |
for i, trace in enumerate(traces): | |
j = i + 1 | |
if j%2==0: | |
j = int(j/2) | |
else: | |
j = int((j+1)/2) | |
fig.append_trace(trace, j, 1) |
This file contains 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 io | |
import dash | |
import dash_html_components as html | |
from flask import send_file | |
import pandas as pd | |
app = dash.Dash() | |
app.layout = html.Div( | |
children=[html.A("download excel", href="/download_excel/")]) |