In [1]:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
In [5]:
%matplotlib inline
plt.plot([0, 1, 2, 3])
plt.show()
In [8]:
# Make the random function consistent and replicable
np.random.seed(1221)
# Make a blank data frame.
df = pd.DataFrame()
# Add a column of random numbers between 0 and 1.
df['rand'] = np.random.rand(100)
df['rand_sq'] = df['rand'] ** 2
df['rand_shift'] = df['rand'] + 2
# When creating a data frame an index column of counts is created, counting from 0.
# Here we do a few transforms on that index to create some extra columns.
df['counts_sq'] = df.index ** 2
df['counts_sqrt'] = np.sqrt(df.index)
In [10]:
plt.plot(df['rand'])
plt.show()
In [11]:
plt.plot(df['rand'], color = 'purple')
plt.ylim([-0.1, 1.1])
plt.ylabel('Values')
plt.title('Random Series')
plt.show()
In [27]:
plt.plot(df['rand'], color = 'purple')
plt.plot(df['rand_shift'], color = "green")
plt.ylim([-0.1, 3.1])
plt.ylabel('Values')
plt.title('Random Series')
plt.show()
In [45]:
plt.scatter(x = df['counts_sqrt'], y = df['counts_sq'])
plt.show()
In [47]:
plt.scatter(
x = df['rand'], y = df['rand_sq'],
color = 'purple', marker = 'x', s = 10
)
plt.scatter(
x = df['counts_sqrt'], y = df['counts_sq'],
color = 'green', marker = 'x', s = 10
)
plt.show()
In [48]:
df.plot(kind = 'scatter', x = 'counts_sq',y = 'counts_sqrt')
df.plot(kind = 'line')
Out[48]:
In [ ]: