Index ¦ Archives ¦ Atom

Hello, Jupyter Notebook!

Hello, Jupyter Notebook !

In [1]:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

%matplotlib inline

Numpy

In [2]:
np.random.seed(100)
In [3]:
# standard normal distribution
data = np.random.randn(100, 2)
In [4]:
data.shape
Out[4]:
(100, 2)

Matplotlib

In [5]:
plt.title("Samples from standard normal distribution")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.plot(data[:, 0])
Out[5]:
[<matplotlib.lines.Line2D at 0x10a8bf400>]
In [6]:
plt.title("Samples from standard normal distribution")
plt.xlim(-5, 5)
plt.ylim(-5, 5)
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.scatter(data[:, 0], data[:, 1])
Out[6]:
<matplotlib.collections.PathCollection at 0x10a9cecf8>

Pandas

In [7]:
d = {'x': data[:, 0], 'y': data[:, 0]}
df = pd.DataFrame(data=d)
In [8]:
df.head()
Out[8]:
x y
0 -1.749765 -1.749765
1 1.153036 1.153036
2 0.981321 0.981321
3 0.221180 0.221180
4 -0.189496 -0.189496
In [9]:
df.describe()
Out[9]:
x y
count 100.000000 100.000000
mean -0.019725 -0.019725
std 1.097580 1.097580
min -2.973315 -2.973315
25% -0.638577 -0.638577
50% -0.042461 -0.042461
75% 0.750447 0.750447
max 2.298654 2.298654

© akimach. Built using Pelican. Theme by Giulio Fidente on github.