728x90
In [39]:
import pandas as pd
import matplotlib.pyplot as plt
import datetime
In [45]:
# 일별 수익률 데이터
return_df = pd.read_csv('crypto_daily_returns.csv'); return_df
Out[45]:
Date | BTC | ETH | LTC | |
---|---|---|---|---|
0 | 09/17/2014 | 0.000000 | 0.000000 | 0.000000 |
1 | 09/18/2014 | -7.192558 | NaN | -7.379983 |
2 | 09/19/2014 | -6.984265 | NaN | -7.629499 |
3 | 09/20/2014 | 3.573492 | NaN | -0.955003 |
4 | 09/21/2014 | -2.465854 | NaN | -0.945300 |
... | ... | ... | ... | ... |
2479 | 07/01/2021 | -4.191449 | -7.075787 | -4.550086 |
2480 | 07/02/2021 | 0.967856 | 1.723823 | -0.460711 |
2481 | 07/03/2021 | 2.276009 | 3.538258 | 2.436037 |
2482 | 07/04/2021 | 1.786156 | 4.294922 | 3.297811 |
2483 | 07/05/2021 | -4.369154 | -5.303886 | -4.715207 |
2484 rows × 4 columns
In [55]:
# A histogram represents data using bars with various heights
mu = round(return_df['BTC'].mean(),2);print('mu:',mu)
sigma = round(return_df['BTC'].std(),2);print('sigma:',sigma)
mu: 0.25
sigma: 3.93
In [56]:
plt.figure(figsize=(12,6))
return_df['BTC'].plot.hist(bins=50, alpha = 0.5)
plt.grid()
plt.title('Histogram: mu= '+ str(mu) + ' sigma= ' + str(sigma))
Out[56]:
Text(0.5, 1.0, 'Histogram: mu= 0.25 sigma= 3.93')
728x90
'Data Analytics with python > [Data Analysis]' 카테고리의 다른 글
[seaborn]S6_01_scatter&count_plot (0) | 2023.01.21 |
---|---|
[matplotlib]S5_appendix_Making_dataset(주식 일별 수익률 계산) (0) | 2023.01.21 |
[matplotlib]S5_06_pie_chart (0) | 2023.01.21 |
[matplotlib]S5_05_Scatterplot (0) | 2023.01.21 |
[matplotlib]S5_04_Sub_plots (0) | 2023.01.21 |
댓글