Skip to content

Instantly share code, notes, and snippets.

View izikeros's full-sized avatar

Krystian Safjan izikeros

View GitHub Profile
@izikeros
izikeros / useful_pandas_snippets.md
Last active March 15, 2024 19:53 — forked from bsweger/useful_pandas_snippets.md
[pandas snippets (fork)] Useful Pandas Snippets #pandas #snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@izikeros
izikeros / notebook_mem_usage.py
Last active July 17, 2024 22:36 — forked from aiguofer/README.md
[notebook memory usage] Find out how much memory each of the jupyter notebooks running on a server is using. Helpful for knowing which ones to shut down. Original code from http://stackoverflow.com/questions/34685825/jupyter-notebook-memory-usage-for-each-notebook
import os
import pwd
import psutil
import re
import string
import requests
import socket
import argparse
import tabulate
import pandas as pd
@izikeros
izikeros / tmux-cheatsheet.markdown
Created June 18, 2019 13:56 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@izikeros
izikeros / start.py
Last active March 15, 2024 20:11 — forked from WillKoehrsen/start.py
[notebook pre-load and pre-config] Script with commands that will be executed upon notebook initialization #notebook #jupyter
"""
If you often use interactive IPython sessions or Jupyter Notebooks and you’re getting tired of importing the same libraries over and over, try this:
Navigate to ~/.ipython/profile_default
Create a folder called startup if it’s not already there
Add a new Python file called start.py
Put your favorite imports in this file
Launch IPython or a Jupyter Notebook and your favorite libraries will be automatically loaded every time!
author: Will Koehrsen
@izikeros
izikeros / useful_pandas_snippets.py
Last active March 14, 2024 09:55 — forked from fomightez/useful_pandas_snippets.py
[useful pandas snippets] useful pandas snippets #pandas #python
# List unique values in a DataFrame column
df['Column Name'].unique()
# convert column to lowercase (without warning working on copy)
df.loc[:, 'url'] = df.loc[:, 'url'].str.lower()
# To extract a specific column (subset the dataframe), you can use [ ] (brackets) or attribute notation.
df.height
df['height']
# are same thing!!! (from http://www.stephaniehicks.com/learnPython/pages/pandas.html
@izikeros
izikeros / stars.sh
Created January 12, 2020 07:55 — forked from sebble/stars.sh
List all starred repositories of a GitHub user.
#!/bin/bash
USER=${1:-sebble}
STARS=$(curl -sI https://api.github.com/users/$USER/starred?per_page=1|egrep '^Link'|egrep -o 'page=[0-9]+'|tail -1|cut -c6-)
PAGES=$((658/100+1))
echo You have $STARS starred repositories.
echo
@izikeros
izikeros / PKGBUILD
Created January 25, 2021 10:53 — forked from valeth/PKGBUILD
[archlinux] PKGBUILD template
# This is an example PKGBUILD file. Use this as a start to creating your own,
# and remove these comments. For more information, see 'man PKGBUILD'.
# NOTE: Please fill out the license field for your package! If it is unknown,
# then please put 'unknown'.
# Maintainer: Your Name <youremail@domain.com>
pkgname=NAME
pkgver=VERSION
pkgrel=1
epoch=
@izikeros
izikeros / restic_backup.sh
Created March 31, 2021 07:52 — forked from zerodahero/restic_backup.sh
Restic backup with .gitignore style excludes
#!/bin/bash
TEMPFILE='/tmp/restic_ignores.txt'
BACKUPDIR=$HOME
# Note: Not sure which way is better, echo nothing into the file, or remove if exists
# if [ -f $TEMPFILE ]; then
# rm $TEMPFILE
# fi
# touch $TEMPFILE
@izikeros
izikeros / script-template.sh
Last active March 14, 2024 10:08 — forked from m-radzikowski/script-template.sh
[safe bash script template] see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/ #bash #script #template
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@izikeros
izikeros / pdshow.py
Created September 22, 2021 18:48 — forked from wassname/pdshow.py
show a pandas data frame in full
from IPython.display import display
import pandas as pd
def pdshow(df):
"""
This shows a pandas dataframe in full/
Also consider .to_html() and https://pbpython.com/dataframe-gui-overview.html