Designed by: Mauricio Bucardo
Original image: https://dribbble.com/shots/5619509-Animated-Tab-Bar
A Pen by Ashkiebear on CodePen.
Designed by: Mauricio Bucardo
Original image: https://dribbble.com/shots/5619509-Animated-Tab-Bar
A Pen by Ashkiebear on CodePen.
CTRL + A : Move the cursor to the beginning of the line
CTRL + E : Move the cursor to the end of the line
OPTION + Left Arrow : Move the cursor one word backward
OPTION + Right arrow : Move the cursor one word forward
Left Arrow : Move the cursor one character backward
Right Arrow : Move the cursor one character forward
| # extraction pattern: ngram TAB year TAB match_count TAB volume_count NEWLINE | |
| # out: unique_ngram TAB sum(match_count) NEWLINE | |
| import re | |
| import os, sys, mmap | |
| from pathlib import Path | |
| from tqdm import tqdm | |
| from concurrent.futures import ThreadPoolExecutor | |
| abv = re.compile(r'^(([A-Z]\.){1,})(_|[^\w])') # A.B.C. |
| { | |
| "cmd": ["/usr/local/var/pyenv/shims/python", "-u", "$file"], | |
| "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", | |
| "selector": "source.python" | |
| } |
| # List unique values in a DataFrame column | |
| df['Column Name'].unique() # Note, `NaN` is included as a unique value. If you just want the number, use `nunique()` which stands | |
| # for 'number of unique values'; By default, it excludes `NaN`. `.nunique(dropna=False)` will include `NaN` in the count of unique values. | |
| # 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 | |
| # -or- | |
| # http://www.datacarpentry.org/python-ecology-lesson/02-index-slice-subset/) |
| import io | |
| from PIL import Image # https://pillow.readthedocs.io/en/4.3.x/ | |
| import requests # http://docs.python-requests.org/en/master/ | |
| # example image url: https://m.media-amazon.com/images/S/aplus-media/vc/6a9569ab-cb8e-46d9-8aea-a7022e58c74a.jpg | |
| def download_image(url, image_file_path): | |
| r = requests.get(url, timeout=4.0) | |
| if r.status_code != requests.codes.ok: |
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)
| #!/usr/bin/env python | |
| """Basic Python Cheat Sheet by Filip Kral on 2015/02/16""" | |
| """ | |
| Python is a cross-platform, interpreted, object-oriented programming language. | |
| That means you can run it on Linux, Windows, Mac, and other platforms, | |
| you don't need to compile your code to execute it because it is compiled on | |
| the fly, and you can use classes and objects. |
| import multiprocessing | |
| import pandas as pd | |
| import numpy as np | |
| def _apply_df(args): | |
| df, func, kwargs = args | |
| return df.apply(func, **kwargs) | |
| def apply_by_multiprocessing(df, func, **kwargs): | |
| workers = kwargs.pop('workers') |