Statement of Completion#4fc6f974
Data Science Tools
easy
Jupyter Notebook Tutorial
Resolution
Activities
Everything is a cell!¶
And here are some empty cells:
In [ ]:
In [ ]:
In [ ]:
Multi mode:
In [1]:
2 + 2
Out[1]:
4
Cell Types¶
This is a markdown cell. It can contain different formatting options as bold, or italic text, code blocks:
def my_function(x, y):
pass
Or even images:
In [2]:
# this is a code cell
2 + 2
Out[2]:
4
Now try it yourself:
Turn this cell into a markdown cell
In [ ]:
Turn this cell into a code cell
Working with code¶
Execute the following cells in order:
In [4]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [5]:
x = np.linspace(0, 10, 500)
y = np.cumsum(np.random.randn(500, 6), 0)
In [6]:
plt.figure(figsize=(12, 7))
plt.plot(x, y)
plt.legend('ABCDEF', ncol=2, loc='upper left')
Out[6]:
<matplotlib.legend.Legend at 0x7658847247d0>
Working with data¶
In [7]:
import pandas as pd
In [8]:
btc = pd.read_csv('btc.csv', index_col='timestamp', parse_dates=True)
In [9]:
eth = pd.read_csv('eth.csv', index_col='timestamp', parse_dates=True)
Bitcoin:
In [10]:
btc.head()
Out[10]:
open | high | low | close | volume | |
---|---|---|---|---|---|
timestamp | |||||
2023-12-01 00:00:00+00:00 | 37731.0 | 37741.0 | 37728.0 | 37741.0 | 4.349545 |
2023-12-01 00:01:00+00:00 | 37739.0 | 37739.0 | 37724.0 | 37724.0 | 1.000053 |
2023-12-01 00:02:00+00:00 | 37721.0 | 37721.0 | 37701.0 | 37701.0 | 0.169017 |
2023-12-01 00:03:00+00:00 | 37703.0 | 37704.0 | 37703.0 | 37704.0 | 0.099991 |
2023-12-01 00:04:00+00:00 | 37703.0 | 37703.0 | 37697.0 | 37697.0 | 0.135919 |
In [11]:
btc.tail()
Out[11]:
open | high | low | close | volume | |
---|---|---|---|---|---|
timestamp | |||||
2023-12-10 10:49:00+00:00 | 43683.0 | 43683.0 | 43683.0 | 43683.0 | 0.000000 |
2023-12-10 10:50:00+00:00 | 43671.0 | 43675.0 | 43671.0 | 43675.0 | 0.008716 |
2023-12-10 10:51:00+00:00 | 43694.0 | 43694.0 | 43694.0 | 43694.0 | 0.003141 |
2023-12-10 10:52:00+00:00 | 43711.0 | 43711.0 | 43709.0 | 43709.0 | 0.029046 |
2023-12-10 10:53:00+00:00 | 43709.0 | 43709.0 | 43709.0 | 43709.0 | 0.000000 |
In [12]:
btc.info()
<class 'pandas.core.frame.DataFrame'> DatetimeIndex: 13698 entries, 2023-12-01 00:00:00+00:00 to 2023-12-10 10:53:00+00:00 Data columns (total 5 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 open 13698 non-null float64 1 high 13698 non-null float64 2 low 13698 non-null float64 3 close 13698 non-null float64 4 volume 13698 non-null float64 dtypes: float64(5) memory usage: 642.1 KB
In [13]:
btc['close'].plot(figsize=(15, 7))
Out[13]:
<Axes: xlabel='timestamp'>
Ether:
In [14]:
eth.head()
Out[14]:
open | high | low | close | volume | |
---|---|---|---|---|---|
timestamp | |||||
2023-12-01 00:00:00+00:00 | 2053.1 | 2054.3 | 2053.1 | 2053.8 | 98.816206 |
2023-12-01 00:01:00+00:00 | 2054.0 | 2054.0 | 2052.9 | 2052.9 | 101.136155 |
2023-12-01 00:02:00+00:00 | 2052.6 | 2052.6 | 2051.2 | 2051.2 | 284.303968 |
2023-12-01 00:03:00+00:00 | 2051.5 | 2052.3 | 2051.3 | 2052.3 | 67.405196 |
2023-12-01 00:04:00+00:00 | 2052.2 | 2052.6 | 2052.1 | 2052.1 | 96.918102 |
In [ ]:
eth['close'].plot(figsize=(15, 7))
In [15]:
eth.head()
Out[15]:
open | high | low | close | volume | |
---|---|---|---|---|---|
timestamp | |||||
2023-12-01 00:00:00+00:00 | 2053.1 | 2054.3 | 2053.1 | 2053.8 | 98.816206 |
2023-12-01 00:01:00+00:00 | 2054.0 | 2054.0 | 2052.9 | 2052.9 | 101.136155 |
2023-12-01 00:02:00+00:00 | 2052.6 | 2052.6 | 2051.2 | 2051.2 | 284.303968 |
2023-12-01 00:03:00+00:00 | 2051.5 | 2052.3 | 2051.3 | 2052.3 | 67.405196 |
2023-12-01 00:04:00+00:00 | 2052.2 | 2052.6 | 2052.1 | 2052.1 | 96.918102 |
Activities¶
1) Fill your name in the placeholder cell and execute it¶
In [16]:
name = "Ayush"
name
Out[16]:
'Ayush'
2) Complete the function add
to produce the right result¶
In [18]:
def add(x, y):
return x+y
add(2, 3)
Out[18]:
5
In [ ]: