This file contains hidden or 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 pandas as pd | |
import seaborn as sns | |
def order_by_correlation_cluster(data: pd.DataFrame, x: str, y: str, values: str) -> pd.DataFrame: | |
"""Takes a tidy dataframe, pivots it, and creates a clustermap based on | |
correlations between rows. Returns the original data with a new 'order' | |
column that contains the cardinal ordering of the y axis from the clustermap. | |
Made with plotting in altair in mind. | |
""" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Wed Jan 2 17:07:42 2019 | |
@author: jdjumalieva | |
""" | |
import pandas as pd | |
import os |
This file contains hidden or 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 string | |
def standardise_column_names(df, remove_punct=True): | |
""" Converts all DataFrame column names to lower case replacing | |
whitespace of any length with a single underscore. Can also strip | |
all punctuation from column names. | |
Parameters | |
---------- | |
df: pandas.DataFrame |
This file contains hidden or 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
from datetime import datetime | |
def timestamp_string(string, file_ext=True, hidden_file=False): | |
""" Adds a timestamp to the end of a string in the format | |
YYYY_MM_DD_hhmm. | |
Parameters: | |
string: str | |
string to be timestamped | |
file_ext: bool |
This file contains hidden or 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
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required |
This file contains hidden or 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
with open('file.txt', 'r') as f: | |
text = f.read() | |
lines_list = text.split('\n') |
This file contains hidden or 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 pandas as pd | |
from sqlalchemy import create_engine | |
from sqlalchemy.engine.url import URL | |
# db settings to make url (could be in external file) | |
db_settings = {'drivername': <database driver>, # 'postgres', 'mysql' etc. | |
'host': <host address>, # 'localhost' etc. | |
'username': <username>, | |
'password': <password>, | |
'database': <database name> |