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
// seen on http://makble.com/how-to-copy-text-from-chrome-console-to-file-using-javascript | |
console.save = function (data, filename) { | |
// code to save console output as a json file | |
if (!data) { | |
console.error('Console.save: No data') | |
return; | |
} | |
if (!filename) filename = 'console.json' |
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
var className = 'your-class-name'; // Replace your-class-name with the class name of the elements you want to click | |
var elements = Array.from(document.getElementsByClassName(className)); | |
elements.map(x => x.click()) |
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 concurrent | |
def parallel_map(function, iterable, max_workers: int = 50): | |
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as pool: | |
result = pool.map(function, iterable) | |
return list(result) |
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 numpy as np | |
# dataviz imports | |
import plotly as py | |
import plotly.express as px | |
import plotly.graph_objs as go | |
import plotly.figure_factory as ff | |
from plotly.subplots import make_subplots | |
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot |
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 | |
data = pd.Series([1, 4, 4, 6, 2, 4, 7, 4, 7]) | |
# data can be a series or a dataframe | |
# this calculates the inverse quantile for each value of data | |
inverse_quantiles = data.apply(lambda x: ((data <= x).sum()) / len(data)) | |
# read more: https://stackoverflow.com/a/58186830/5031446 |
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
{%- extends 'full.tpl' -%} | |
{%- block header -%} | |
{{ super() }} | |
<meta name='robots' content='noindex,nofollow' /> | |
{%- endblock header -%} | |
{% block any_cell %} |
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
# plotly imports | |
import plotly.plotly as py | |
import plotly.graph_objs as go | |
from plotly.offline import init_notebook_mode, plot, iplot | |
import cufflinks as cf | |
init_notebook_mode(connected=True) | |
cf.go_offline() |
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 numpy as np | |
def ratio(ret1: pd.Series, | |
ret2: pd.Series = 0, | |
ratio: str = 'sharpe', | |
log: bool = True) -> float: | |
"""log: if True, convert ret1 and ret2 to log returns""" | |
if log: | |
ret1 = np.log1p(ret1) |
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 tqdm import tqdm | |
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor, as_completed | |
def parallel_process(array, | |
function, | |
type_pool: str = 'multithreading', | |
use_kwargs=False, | |
n_jobs=16, | |
front_num=3, |
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
df_gridsearch['size'] = (df_gridsearch.mean_test_score / | |
df_gridsearch.mean_test_score.max()) ** 100 * 20 + 1 |