Skip to content

Instantly share code, notes, and snippets.

View EdMan1022's full-sized avatar
💭
working

Edward Brennan EdMan1022

💭
working
  • Red Hat
  • Raleigh, NC
View GitHub Profile
from flask import Blueprint, request
from ..helper_functions import cluster_analysis_function
analytics = Blueprint('analytics', __name__, template_folder='templates')
@analytics.route('/api/analytics/cluster_analysis', methods=['GET'])
def cluster_analysis_view():
"""
@EdMan1022
EdMan1022 / scratch.jinja2
Created November 27, 2017 18:29
Ajax trouble
{% extends 'utilities/base.html' %}
{% block title %}{{ analysis_group.name }}{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-8">
<div class="card border-primary mb-3">
<div class="card-header">
<h3>{{ analysis_group.name }}</h3>
<h4>{{ analysis_group.description }}</h4>
</div>
@EdMan1022
EdMan1022 / Flask-blueprint-with-imported-routes
Created November 7, 2017 18:02 — forked from Jaza/Flask-blueprint-with-imported-routes
Example of how to split a Flask blueprint into multiple files, with routes in each file, and of how to register all those routes.
*
@EdMan1022
EdMan1022 / df_to_txt.py
Created September 22, 2017 15:52
Pandas dataframe to txt file with comma delimiter test
import pandas as pd
# Pandas dataframe to txt file with comma delimiter test
df = pd.DataFrame(index = [0,1,2,3,4])
df.loc[:, 'a'] = 'a'
df.loc[:, 'b'] = 2
df.loc[:, 'c'] = ' '
df.loc[:, 'd'] = None
@EdMan1022
EdMan1022 / null_categorical_variables.py
Created September 1, 2017 21:24
Create a dataframe with null variable columns indicating indices with null values for each column
import pandas as pd
import numpy as np
df = pd.DataFrame(data=[[3., 1., np.NaN], [np.NaN, 3., 2.], [4., 1., 3.]], index=[0, 1, 2],
columns=['apple', 'carrot', 'pear'])
def null_only_categorical_func(data):
"""
Take a series, and return values of 1. where the series is null
@EdMan1022
EdMan1022 / scratch_9.py
Created August 11, 2017 20:06
sklearn pca example
from sklearn import decomposition
import numpy as np
pca = decomposition.PCA(n_components=2)
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
x = pca.fit_transform(X)