Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
Last active Nov 6, 2020
Embed
What would you like to do?
Coefficient variable to compare your crypto assets
import matplotlib.pyplot as plt
import seaborn as sns
now = datetime.datetime.utcnow()
path = 'data/' + 'coefficientVariable_' + now.strftime('%Y%m%d_%H%M%S') + '.png'
# seaborn drawing
sns.set_style('whitegrid')
sns.set_palette("PuBu", 8)
sns.set_context(context='paper', font_scale=2, rc=None)
# Coefficient of variation per asset
fig = plt.figure(figsize=(15, 7))
ax = fig.add_subplot(1, 1, 1)
# calculate coefficient of variation,
# represents the ratio of the standard deviation to the mean
cv = pd.DataFrame(df_.std()/df_.mean())
cv.columns = ['Coef']
ax.set_title('Coefficient of variation per crypto asset')
sns_plot = sns.barplot(data=cv.T)
figure = sns_plot.get_figure()
figure.savefig(path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment