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
# see: https://stackoverflow.com/a/1806873/3247880 | |
digraph G { | |
a -> b [ label=" a to b" ]; | |
b -> c [ label=" another label"]; | |
} |
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
; Configuration for Flake8 with plugins: | |
; flake8-bugbear, | |
; flake8-commas, | |
; flake8-docstrings, | |
; flake8-print, | |
; flake8-pytest, | |
; flake8-pytest-mark | |
; flake8-import-order | |
[flake8] |
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 matplotlib import pyplot as plt | |
"""If used in Jupyter notebook, this can be embedded by adding cell: | |
%%bash | |
if [ ! -e matplotlib_styling.py ]; then | |
wget https://gist.githubusercontent.com/izikeros/457a99d950310da8166050a13f4043cb/raw/4334d77bdaad867003926e7cf87ffbec7131528d/matplotlib_styling.py | |
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
""" | |
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 |
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: | |
# https://stackoverflow.com/a/34365537/3247880 | |
# see internals: | |
# https://github.com/tqdm/tqdm/blob/master/examples/pandas_progress_apply.py | |
import pandas as pd | |
import numpy as np | |
from tqdm import tqdm | |
# from tqdm.auto import tqdm # for notebooks |
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
# See: plot_enhancements.py gist | |
def add_value_labels_barh(ax, spacing=5): | |
""" | |
Add labels to the end of each bar in a barh chart. | |
Tip: usually one need to add expansion of xlimit to keel labels inside plot, e.g.: | |
ax.set_xlim(0, 1.1) | |
Arguments: | |
ax (matplotlib.axes.Axes): The matplotlib object containing the axes |
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
# 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 |
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
# convert to datetime without warnings | |
meta_df= meta_df.astype({'eventDate': 'datetime64'}) |
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
# if received key in format: | |
#—- BEGIN SSH2 PUBLIC KEY —- | |
# | |
#Comment: "rsa-key-20160402" | |
#AAAAB3NzaC1yc2EAAAABJQAAAgEAiL0jjDdFqK/kYThqKt7THrjABTPWvXmB3URI | |
# | |
# and you want to add it to authorized keys | |
# from: https://tutorialinux.com/convert-ssh2-openssh/ | |
ssh-keygen -i -f coworker.pub >> ~/.ssh/authorized_keys |
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 wordcloud import WordCloud | |
wordcloud = WordCloud(background_color='white', | |
width=1500, | |
height=1000 | |
).generate_from_frequencies(dictionary) | |
# use .generate(space_separated_string) - to generate cloud from text | |
plt.figure(figsize=(9,6)) | |
plt.imshow(wordcloud) |