Skip to content

Instantly share code, notes, and snippets.

View hsteinshiromoto's full-sized avatar

Humberto STEIN SHIROMOTO hsteinshiromoto

View GitHub Profile
// .stglobalignore
// Incomplete Downloads
// At least for now, these prevent Syncthing from transferring data that's
// going to be thrown out anyway once the download is finished and the
// file is renamed. Things may change when Syncthing gets smarter.
//
// Git //
.git
// Firefox downloads and other things
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env bash
# This file automatically updates the versions of files setup.py and __init__.py
# based on the latest git tag and the release branch name
# Copy this file to .git/hooks/
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
BRANCH_TYPE=$(echo ${BRANCH_NAME}| cut -d/ -f1)
NEXT_VERSION=$(echo ${BRANCH_NAME} | cut -d "v" -f2- | cut -d "v" -f2-)
@hsteinshiromoto
hsteinshiromoto / nx.plotgraph.py
Last active September 3, 2021 04:26
nx.plotgraph
from collections.abc import Iterable
import matplotlib as mpl
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
def make_graph(nodes: Iterable, M: np.ndarray, G: nx.classes.digraph.DiGraph=nx.DiGraph()):
"""Build graph based on list of nodes and a weight matrix
@hsteinshiromoto
hsteinshiromoto / date_xticklabels.py
Created August 8, 2021 23:58
Set dates in x tick labels
fig, ax = plt.subplots(figsize=(20, 10))
ax = sns.lineplot(x=xticks, y=y, ax=ax)
plt.xticks(xticks, data["datetime_column_label"].astype(str), rotation=30, ha="right")
@hsteinshiromoto
hsteinshiromoto / BayesianSearchCV.py
Last active July 20, 2021 23:30
bayesiansearchcv.py
import sys
import traceback
from collections.abc import Iterable
from typing import Union
from hyperopt import STATUS_FAIL, STATUS_OK, Trials, fmin, hp, tpe
import pandas as pd
import numpy as np
import scipy as sp
from sklearn.model_selection import KFold, StratifiedKFold
try:
import module
except ModuleNotFoundError:
exc_info = sys.exc_info()
traceback.print_exception(*exc_info)
del exc_info
@hsteinshiromoto
hsteinshiromoto / bin_bars.py
Created July 13, 2021 11:47
Plotting binarized bars
fig, ax = plt.subplots()
ax = sns.barplot(x=df.index, y=df["Column"])
ax.set_xlabel("X Label")
x = list(df["Bins"].astype(str).values)
x[-1] = f'{df["Bins"].max().left}+'
plt.xticks(df.index, x)
@hsteinshiromoto
hsteinshiromoto / max_value_in_group.py
Created July 8, 2021 06:23
Get the row(s) which have the max value in groups using groupby
# References:
# [1] https://stackoverflow.com/questions/15705630/get-the-rows-which-have-the-max-value-in-groups-using-groupby
# Get data
import pandas as pd
df = pd.DataFrame({'category': ['banana', 'eggs', 'eggs', 'full cream milk', 'full cream milk', 'full cream milk'],
'unit_quantity': ['1EA', '100G', '100ML', '100G', '100ML', '1L'],
'Count': [5, 22, 1, 5, 1, 38],},
index = [0, 1, 2, 3, 4, 5])
@hsteinshiromoto
hsteinshiromoto / .gitignore
Last active March 22, 2023 23:59
Complete gitignore
# Created by https://www.toptal.com/developers/gitignore/api/tex,latex,linux,macos,python,dbeaver,pycharm,windows,jupyternotebooks,visualstudiocode,obsidian
# Edit at https://www.toptal.com/developers/gitignore?templates=tex,latex,linux,macos,python,dbeaver,pycharm,windows,jupyternotebooks,visualstudiocode,obsidian
## Syncthing ##
.stfolder/
.stversions/
### DBeaver ###
# ide config file