A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| # Prevent from using the custom alias on 3rd party scripts. Must be at the top of the file | |
| [ -z "$PS1" ] && return | |
| # alias | |
| alias blog='cd ~/projects/blog' | |
| alias blog-posts='cd ~/projects/blog/content/blog' | |
| alias .zshrc='nvim ~/.zshrc' | |
| alias gitlog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" | |
| alias wifi='nmcli device show wlan0' | |
| function cd { |
| wget https://storage.googleapis.com/golang/go1.10.1.linux-armv6l.tar.gz | |
| sudo tar -C /usr/local -xvf go1.10.1.linux-armv6l.tar.gz | |
| cat >> ~/.bashrc << 'EOF' | |
| export GOPATH=$HOME/go | |
| export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin | |
| EOF | |
| source ~/.bashrc |
| #!/bin/bash | |
| ############################################################################## | |
| # BASH BASICS | |
| ############################################################################## | |
| env # displays all environment variables | |
| echo $SHELL # displays the shell you're using | |
| echo $BASH_VERSION # displays bash version |
| const echoPostRequest = { | |
| url: 'https://<my url>.auth0.com/oauth/token', | |
| method: 'POST', | |
| header: 'Content-Type:application/json', | |
| body: { | |
| mode: 'application/json', | |
| raw: JSON.stringify( | |
| { | |
| client_id:'<your client ID>', | |
| client_secret:'<your client secret>', |
| #!/bin/bash | |
| export DEBIAN_FRONTEND=noninteractive; | |
| echo "[*] Starting Install... [*]" | |
| echo "[*] Upgrade installed packages to latest [*]" | |
| echo -e "\nRunning a package upgrade...\n" | |
| apt-get -qq update && apt-get -qq dist-upgrade -y | |
| apt full-upgrade -y | |
| apt-get autoclean | |
| echo "[*] Install stuff I use all the time [*]" |
| #!/usr/bin/env python | |
| # -*- encoding: utf-8 -*- | |
| """ An efficient and simple ANSI colours module (and also a powerfull script), with functions to print text using colours. | |
| About the convention for the names of the colours : | |
| * for the eight colours black, red, green, yellow, blue, magenta, cyan, white: | |
| * the name in minuscule is for colour **with bold** (example 'yellow'), | |
| * the name starting with 'B' is for colour **without bold** (example 'Byellow'), | |
| * the name starting with a capital letter is for the background colour (example 'Yellow').* for the special effects (blink, italic, bold, underline, negative), **not always supported** : |
| const countryCodes = { | |
| US: 'United States', | |
| CA: 'Canada', | |
| NG: 'Nigeria', | |
| GB: 'United Kingdom', | |
| }; | |
| const sales = [ | |
| { code: 'US', count: 233 }, |
| type FilterOperator = 'AND' | 'OR'; | |
| type FiltersBy<T> = { | |
| [K in keyof T]?: (value: T[K]) => boolean; | |
| }; | |
| /** | |
| * Factory function that creates a specialized function to filter | |
| * arrays, by validating all filters (AND operator), | |
| * or validating just one of the filters (OR operator). | |
| * @param operator Method to validate all filters: AND, OR |
| /** | |
| * Primary application logic for our Functional Programming blog example | |
| * See related blog series at: http://www.datchley.name/tag/functional-programming/ | |
| * Version: 2.0 | |
| */ | |
| // A simple, resuable comparison for '>=' | |
| function greaterThanOrEqual(a, b) { | |
| return a >= b | |
| } |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)