Skip to content

Instantly share code, notes, and snippets.

@omnisis
Last active August 29, 2015 13:55
Show Gist options
  • Save omnisis/8701128 to your computer and use it in GitHub Desktop.
Save omnisis/8701128 to your computer and use it in GitHub Desktop.
Pandas / Matplotlib Goodies
# Creating a new plot with no spacing
fig, axes = plt.subplots(2, 2, sharex=True, sharey=True) for i in range(2):
for j in range(2):
axes[i, j].hist(randn(500), bins=50, color='k', alpha=0.5)
plt.subplots_adjust(wspace=0, hspace=0)
# useful bar graph
series.value_counts().plot(kind='bar/barh')
# Pandas Data cleanup
data = data[(data.LATITUDE > 18) & (data.LATITUDE < 20) & ....: (data.LONGITUDE > -75) & (data.LONGITUDE < -70) ....: & data.CATEGORY.notnull()]
# TopN
def top(df, n=5, column):
return df.sort_index(by=column)[-n:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment