This file contains 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
function stash() { | |
# Check if stash is empty | |
if ! git stash list &>/dev/null; then | |
echo "No stashes found." | |
return | |
fi | |
# Fetch relative dates and messages from git stash | |
local relative_dates=$(git stash list --format="%ar") | |
local messages=$(git stash list --format="%gs" | sed 's/^On //; s/^WIP on //') |
This file contains 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 json | |
import polars as pl | |
def dtype_to_json(dtype: pl.DataType) -> str: | |
return json.dumps(str(dtype)) | |
def json_to_dtype(json_dtype_str: str) -> pl.DataType: | |
from polars.datatypes.classes import ( # noqa F401 | |
Array, |
This file contains 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
[[language]] | |
name = "python" | |
scope = "source.python" | |
injection-regex = "python" | |
file-types = ["py","pyi","py3","pyw",".pythonstartup",".pythonrc"] | |
shebangs = ["python"] | |
roots = [".", "pyproject.toml", "pyrightconfig.json"] | |
comment-token = "#" | |
language-servers = ["pyright", "ruff"] | |
indent = { tab-width = 4, unit = " " } |
This file contains 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 typing import Any | |
import polars as pl | |
import json | |
from pydantic import BaseModel | |
original_expression = (pl.col("foo") * 2) == pl.col("bar") | |
class Column(BaseModel, arbitrary_types_allowed=True): |
This file contains 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
[[language]] | |
name = "python" | |
scope = "source.python" | |
injection-regex = "python" | |
file-types = ["py","pyi","py3","pyw",".pythonstartup",".pythonrc"] | |
shebangs = ["python"] | |
roots = [".", "pyproject.toml", "pyrightconfig.json"] | |
comment-token = "#" | |
language-servers = ["pyright", "ruff"] | |
indent = { tab-width = 4, unit = " " } |
This file contains 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 typing import Any | |
import json | |
import structlog | |
import pandas as pd # pip install pandas | |
import polars as pl # pip install polars | |
from pydantic import BaseModel | |
class PydanticModel(BaseModel): | |
a: int | |
b: str |
This file contains 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
[[language]] | |
name = "python" | |
scope = "source.python" | |
injection-regex = "python" | |
file-types = ["py","pyi","py3","pyw",".pythonstartup",".pythonrc"] | |
shebangs = ["python"] | |
roots = [".", "pyproject.toml", "pyrightconfig.json"] | |
comment-token = "#" | |
language-servers = ["pyright", "ruff"] | |
indent = { tab-width = 4, unit = " " } |
This file contains 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
branch () { | |
branches=$(git for-each-ref --sort=-committerdate refs/heads/ --format='%(color:cyan)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:magenta)%(authorname)%(color:reset)' --color=always|column -ts'|') && | |
branch=$(echo "$branches" | fzf --multi --ansi --height=20%) | |
if [ -z "${branch}" ]; | |
then return 0 | |
else git switch $(echo "$branch" | sed "s/ .*//") | |
fi | |
} |
This file contains 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
venv () { | |
RED='\033[0;31m' | |
NC='\033[0m' # No Color | |
# create virtualenv | |
if [ ! -d .venv ] # if venv does not exist already | |
then | |
python -m venv .venv --system-site-packages | |
else | |
echo -e "${RED}.venv${NC} already exists!" | |
return 0 |
This file contains 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
def train_test_split( | |
df: pl.DataFrame, train_fraction: float = 0.75 | |
) -> Tuple[pl.DataFrame, pl.DataFrame]: | |
"""Split polars dataframe into two sets. | |
Args: | |
df (pl.DataFrame): Dataframe to split | |
train_fraction (float, optional): Fraction that goes to train. Defaults to 0.75. |
NewerOlder