Important shortcuts:
Two modes:
import numpy as np
np.bincount()
np.bincount?
Use the help to find out what the options to np.unique
are.
Use np.unique to convert the array ['one', 'two', 'three', 'one', 'two', 'three']
into the array [0, 2, 1, 0, 2, 1]
.
ar = ['one', 'two', 'three', 'one', 'two', 'three']
# your solution here
Need to use either
% matplotlib inline
or
% matplotlib notebook
Only one in each notebook!
using inline
will just sent png
images to browser, using notebook
will provide
interactivity and allow updating old figures.
With notebook
you need to make sure to create a new figure before plotting, otherwise the last one will be updated!
%matplotlib notebook
import matplotlib.pyplot as plt
X = np.random.normal(size=(12, 2))
plt.scatter(X[:, 0], X[:, 1])
plt.plot(X[:, 0])
# create a new figure
plt.figure()
plt.plot(X[:, 0])
Create a new figure and plot a sin wave. You can use np.linspace
to create equally spaced numbers in a given range.
import *
x = 1
x = x + 1
print(x)
Avoid cells you can't run again:
data = {'a': [1, 2, 3], 'b': [999, 1, 2]}
column_a = data.pop('a')
print(column_a)
print(data)
x = 1
x2 = x + 1
print(x2)
Rewrite the code for the data
dict above so that you don't mutate data
, but that the print
stays the same.
# solution Here