Python Cheatsheet

SEABORN BARS

Variable size

g = sns.FacetGrid(...)
g.map(plt.scatter, x_var, y_var, size_var)

Bar chart of count

seaborn.countplot(x='reputation', data=df)

To do it with barplot you’d need something like this:

seaborn.barplot(x=df.reputation.value_counts().index, y=df.reputation.value_counts())

## ok but really proud of these visuals

V4-16

Plotting a table using matplotlib

SO

BAR CHARTS!!

BAR CHARTS!!

Change colors in heatmaps

heatmaps

Pretty confusion matrix

pretty blue squares

ZOOM IN

plt.xlim(0.5,0.7) plt.ylim(0.5,0.7)

Change order of bar charts

add order=['one', 'two','three']

like so

sns.catplot(x="Answer.sentiment.label", 
            y="WorkTimeInSeconds", 
            kind="bar", 
            order=['Negative', 'Neutral', 'Positive'], 
            data=pos)
plt.title('Positive')

SEABORN GROUPBY

```python df_2 = df.groupby(‘A’).sum() df_2.reset_index(inplace=True) sns.barplot(x=’A’, y=’B’, data=df_2);