In [1]:
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
df = pd.read_csv('BTC-USD.csv')
print(df.head(5))
         Date        Open        High         Low       Close   Adj Close  \
0  2014-10-01  387.427002  411.697998  289.295990  338.321014  338.321014   
1  2014-11-01  338.649994  457.092987  320.626007  378.046997  378.046997   
2  2014-12-01  378.248993  384.037994  304.231995  320.192993  320.192993   
3  2015-01-01  320.434998  320.434998  171.509995  217.464005  217.464005   
4  2015-02-01  216.867004  265.610992  212.014999  254.263000  254.263000   

       Volume  
0   902994450  
1   659733360  
2   553102310  
3  1098811912  
4   711518700  
In [2]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 99 entries, 0 to 98
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype  
---  ------     --------------  -----  
 0   Date       99 non-null     object 
 1   Open       99 non-null     float64
 2   High       99 non-null     float64
 3   Low        99 non-null     float64
 4   Close      99 non-null     float64
 5   Adj Close  99 non-null     float64
 6   Volume     99 non-null     int64  
dtypes: float64(5), int64(1), object(1)
memory usage: 5.5+ KB
In [3]:
df['Date'] = pd.to_datetime(df['Date'], format='%Y-%m-%d')
In [4]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 99 entries, 0 to 98
Data columns (total 7 columns):
 #   Column     Non-Null Count  Dtype         
---  ------     --------------  -----         
 0   Date       99 non-null     datetime64[ns]
 1   Open       99 non-null     float64       
 2   High       99 non-null     float64       
 3   Low        99 non-null     float64       
 4   Close      99 non-null     float64       
 5   Adj Close  99 non-null     float64       
 6   Volume     99 non-null     int64         
dtypes: datetime64[ns](1), float64(5), int64(1)
memory usage: 5.5 KB
In [5]:
print(len(df[df['Date'].isna()]))
0
In [6]:
df['Open'].describe()
Out[6]:
count       99.000000
mean     12801.544467
std      16185.720294
min        216.867004
25%        686.925995
50%       7044.810059
75%      15640.101074
max      61320.449219
Name: Open, dtype: float64
In [7]:
df['High'].describe()
Out[7]:
count       99.000000
mean     15238.411850
std      18922.389644
min        247.804001
25%        767.113495
50%       9008.314453
75%      19919.131836
max      68789.625000
Name: High, dtype: float64
In [8]:
df['Low'].describe()
Out[8]:
count       99.000000
mean     10696.337298
std      13336.132579
min        171.509995
25%        644.994995
50%       6136.419922
75%      14421.103515
max      53569.765625
Name: Low, dtype: float64
In [9]:
df['Close'].describe()
Out[9]:
count       99.000000
mean     12968.641746
std      16148.108009
min        217.464005
25%        723.331482
50%       7193.599121
75%      16885.576172
max      61318.957031
Name: Close, dtype: float64
In [10]:
df['Adj Close'].describe()
Out[10]:
count       99.000000
mean     12968.641746
std      16148.108009
min        217.464005
25%        723.331482
50%       7193.599121
75%      16885.576172
max      61318.957031
Name: Adj Close, dtype: float64
In [11]:
df['Volume'].describe()
Out[11]:
count    9.900000e+01
mean     4.997725e+11
std      5.564584e+11
min      5.531023e+08
25%      3.505475e+09
50%      1.991007e+11
75%      9.239591e+11
max      2.267153e+12
Name: Volume, dtype: float64
In [12]:
df['Open'].hist(bins=10, range=(0, 25000));
In [13]:
df['Close'].hist(bins=10, range=(0, 25000));
In [14]:
df['Low'].hist(bins=10, range=(0, 25000));
In [15]:
df['High'].hist(bins=10, range=(0, 25000));
In [16]:
df['Open'].plot();
In [17]:
df['Close'].plot();
In [18]:
df['Low'].plot();
In [19]:
df['High'].plot();
In [20]:
df['Adj Close'].plot();
In [21]:
df['Volume'].plot();
In [22]:
df.plot(x='Date', y='Open', kind='scatter');
In [23]:
df.plot(x='Date', y='Close', kind='scatter');
In [24]:
df.plot(x='Date', y='Low', kind='scatter'); 
In [25]:
df.plot(x='Date', y='High', kind='scatter'); 
In [26]:
df.plot(x='Date', y='Adj Close', kind='scatter'); 
In [27]:
df.plot(x='Date', y='Volume', kind='scatter');
In [28]:
df_open = df.pivot_table(index='Date', values='Open', aggfunc='mean')
df_open.plot(title="Средний показатель биткоина по года Open", style="o-", grid=True, figsize=(15,5));
In [29]:
df_close = df.pivot_table(index='Date', values='Close', aggfunc='mean')
df_close.plot(title="Средний показатель биткоина по года Close", style="o-", grid=True, figsize=(15,5));
In [30]:
df_low = df.pivot_table(index='Date', values='Low', aggfunc='mean')
df_low.plot(title="Средний показатель биткоина по года Low", style="o-", grid=True, figsize=(15,5));
In [31]:
df_high = df.pivot_table(index='Date', values='High', aggfunc='mean')
df_high.plot(title="Средний показатель биткоина по года High", style="o-", grid=True, figsize=(15,5));
In [32]:
df_Adj_Close = df.pivot_table(index='Date', values='Adj Close', aggfunc='mean')
df_Adj_Close.plot(title="Средний показатель биткоина по года Adj Close", style="o-", grid=True, figsize=(15,5));
In [33]:
df_volume = df.pivot_table(index='Date', values='Volume', aggfunc='mean')
df_volume.plot(title="Средний показатель биткоина по года Volume", style="o-", grid=True, figsize=(15,5));
In [40]:
plt.figure(figsize=(25,7))
plt.plot(df['Date'], df['Open'], label = 'Open')
plt.plot(df['Date'], df['Close'], label = 'Close')
plt.plot(df['Date'], df['High'], label = 'High')
plt.plot(df['Date'], df['Low'], label = 'Low')
plt.plot(df['Date'], df['Adj Close'], label = 'Adj Close')
plt.xticks(rotation=90) 
plt.ylabel('Выручка')
plt.title('Графики')
plt.legend()
plt.show()
In [39]:
plt.figure(figsize=(25,10))
plt.plot(df['Date'], df['Volume'], label = 'Open')
plt.xticks(rotation=90) 
plt.ylabel('Выручка')
plt.title('Графики')
plt.legend()
plt.show()
In [ ]: