Skip to content

Instantly share code, notes, and snippets.

View kix2mix2's full-sized avatar
🏠
Working from home

Cristina Morariu kix2mix2

🏠
Working from home
  • London/Stuttgart
View GitHub Profile
@kix2mix2
kix2mix2 / grid_scatterplot_of_images.py
Last active February 12, 2020 15:33
Scatterplot of images (grid version)
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)
@kix2mix2
kix2mix2 / kcng.py
Created January 27, 2020 16:53
K-Nearest Center of Gravity Graph (KNCG)
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 = []
@kix2mix2
kix2mix2 / gong.py
Last active January 27, 2020 16:52
γ -Observable Neighbor Graph (GONG) from Pandas dataframe
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"]])
@kix2mix2
kix2mix2 / stacked_plots.py
Last active September 25, 2018 11:29
Dash / Plotly Subplots with Confidence Intervals
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)
@kix2mix2
kix2mix2 / download_excel.py
Created September 25, 2018 11:14
Download Excel File in a Dash app
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/")])