Last active
November 6, 2020 10:39
-
-
Save yuyasugano/6d78208177a94921ef765c3232a3b00b to your computer and use it in GitHub Desktop.
Coefficient variable to compare your crypto assets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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