-
Notifications
You must be signed in to change notification settings - Fork 2
/
viz_helpers.py
32 lines (26 loc) · 910 Bytes
/
viz_helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import pandas as pd
import itertools
from reddit_counts import prefixes, suffixes
WIKT_FNAME = 'wikt.csv'
#DEFAULT_COUNT_FNAME = 'all_reddit_counts.tsv'
DEFAULT_COUNT_FNAME = 'counts.csv'
def load_df(fname=DEFAULT_COUNT_FNAME, wikt=True):
sep = '\t' if fname.endswith('.tsv') else ','
df = pd.read_csv(fname, sep=sep)
if wikt:
wdf = pd.read_csv(WIKT_FNAME)
df = df.merge(wdf)
return df
def all_compounds():
return [pre+suff for (pre, suff) in itertools.product(prefixes, suffixes)]
BLOGDIR = os.path.expanduser("~/src/colinmorris.github.com/assets/compound_curses/")
def savefig(fig, name, **kwargs):
if '.' not in name:
name += '.png'
path = os.path.join(BLOGDIR, name)
# Default to doubling dpi to make these less squinty
kws = kwargs.copy()
if 'dpi' not in kwargs:
kws['dpi'] = fig.dpi * 2
fig.savefig(path, **kws)