Skip to content

Instantly share code, notes, and snippets.

Last active November 6, 2020 10:39
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_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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment