Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jkw552403
jkw552403 / cli_share_options.py
Created March 25, 2019 08:33
click share options #python #click
def common_params(func):
@click.option('--foo')
@click.option('--bar')
@functools.wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper
@click.command()
@jkw552403
jkw552403 / interactivity
Created November 7, 2018 05:41
[Notebook Interactivity] Show all outputs in a notebook cell #Python #Notebook
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
@jkw552403
jkw552403 / figure
Last active August 17, 2018 03:03
Single plt plot #viz
plt.figure(figsize=(8, 8))
plt.show()
@jkw552403
jkw552403 / wordcloud
Created August 17, 2018 03:03
wordcloud #Python #viz
wc = WordCloud(background_color="white", max_words=1000,
stopwords=STOPWORDS,width=1000,height=1000)
wc.generate(texts with space)
plt.imshow(wc)
plt.show()
@jkw552403
jkw552403 / subplot
Created August 17, 2018 03:02
subplot
fig, ax = plt.subplots(nrows, ncols, figsize=(8, 8))
@jkw552403
jkw552403 / main.py
Last active June 6, 2018 03:37
python main script with click
import click
@click.command()
def main():
pass
if __name__ == "__main__":
main()
import re
sent = 'a b c b c c A B C B C C'
match = re.search('\w+', sent)
while match:
word = match.group()
sent, count = re.subn(word, '', sent, flags=re.I)
match = re.search('\w+', sent)
print(word, count)
# -*- coding: utf-8 -*-
import sys
import unicodedata
table = {c: u' ' for c in range(sys.maxunicode)
if unicodedata.category(unichr(c)).startswith('P')}
def remove_punctuation(s):
return s.translate(table)
import sys
import unicodedata
table = {c: ' ' for c in range(sys.maxunicode)
if unicodedata.category(chr(c)).startswith('P')}
def remove_puntuation(s):
return s.translate(table)