Professional Documents
Culture Documents
Notes 1
Notes 1
In this lesson you will learn how to read data, select subsets of it and generate useful plots,
using pandas and matplotlib. The documentation links below are for your reference.
Read stock data from CSV files:
pandas.DataFrame
pandas.read_csv
Select desired rows and columns:
Indexing and Slicing Data
Gotchas: Label-based slicing conventions
Visualize data by generating plots:
Plotting
pandas.DataFrame.plot
matplotlib.pyplot.plot
Lesson summary
Numpy:
numpy.ndarray.shape: Dimensions (height, width, ...)
numpy.ndarray.ndim: No. of dimensions = len(shape)
numpy.ndarray.size: Total number of elements
numpy.ndarray.dtype: Datatype
Documentation:
time.time: Current time in seconds (float value)
timeit: Average execution time measurement
profile: Code profiling
iPython "magics":
%time: How long does it take to run once
%timeit: Averaged over multiple runs
%prun/%lprun: Per-function/line profiling
You can also access the values that meet a certain condition…
Arithmetic operations on arrays are element-wise. For matrix operations use relavant
functions..
numpy.add: Element-wise addition, same as + operator
numpy.subtract: Element-wise subtraction, same as -
numpy.multiply: Element-wise multiplication, same as *
numpy.divide: Element-wise division, same as /
numpy.dot: Dot product (1D arrays), matrix multiplication (2D)
Note: Arrays need to be compatible with each other for these operations to work
(see: Broadcasting).
For more matrix operations, see: Linear algebra and the matrix class.