A. Dictionary
1 Overview
Is a key-value dictionary of the mapping, wherein the key must be immutable type, and the elements are unordered dictionary, Dictionary identified by {}
2. Create
{Key: value ...} or dict () Sequence
ps1: When creating the dictionary, the default value may be designated by {} .fromkeys ((key_tuple), default)
ps2: zip function can use two element package generated sequence corresponding dictionary
3. Basic Operation
Members of the judge: in
Delete the specified key-value pairs: del dictionary name [key]
4. Functions
dict()、lec()、hash()
keys (), values () return the dictionary of all the key and value all
5. traversal
for k, v in dict.items():...
6. Other
clear()、update、get()等
II. Collection
1 Overview
set (), which is a random combination of elements will not be repeated, and set into a variable set of immutable collection frozenset
2. Operation
Comparison operations: in, not in, ==, =, <, <=,>,> =!
The relational operators: &, |, -, ^
A little built-in functions ....
Data structure of three .SciPy
1 Overview
ndarray (N-dimensional array)
Series (longer dictionary)
DataFrame (data block)
2. The three SciPy library
a.Numpy
A strong ndarray objects and ufunc functions, linear algebra for scientific computing and processing a random number
b.Matplotlib
Based Numpy, is a two-dimensional graphics library, common pyplot module provides an interface similar to the MATLAB
c.pandas
Based Scipy and Numpy, provides efficient and DataFrame Series data structure, efficient data collection slice function
Four .ndarray
1 Overview
ndarray is the basic data structure of NumPy, all elements are of the same type, with a wealth of functions
2. Basic properties
ndarray.ndim 秩
ndarray.shape dimension
The total number of elements ndarray.size
ndarray.dtype element type
byte size elements ndarray.itemsize
3. Create
方法:array、arange、random、linspace、ones、zeros、fromfunction
import numpy as np aArray = np.array([1,2,3]) bArray = np.array([(1,2,3),(4,5,6)]) np.arange(1,5,0.5) np.random.random((2,2)) np.linspace(1,2,10,endpoint=False)
4. Operation
Indexing, slicing, traverse, reshape, resize, stitching vstack, bstack
Support basic operators: /> - *
5. Application - Linear Algebra
dot: the matrix product
linalg.det determinant
linalg.inv inverse matrix
linalg.solve finding roots of multivariate linear equation
linalg.elg find eigenvalues and eigenvectors
V. longer dictionary Series
1 Overview
A dictionary is an unordered data structure, and does not separate between the key value, and a fixed-length Series ordered dictionary, are independent between the index and its value; one-dimensional array of similar objects, the data and the composition of the index
2.