Please enable JavaScript.
Coggle requires JavaScript to display documents.
Python Lists (列表) (List methods:
index(), find index of the first match;…
List methods:
- index(), find index of the first match;
- count(), get the number of times element appears;
- append();
- remove();
- reverse();
-
-
Python list:
- Data can be built in lists in [x, y, z, ...];
- List can contain different types;
- Subsetting List:
- Use index to select data from a list:
- [0] first index;
- [-1] last index;
- Slicing is to select multiple values in a list:
- [3:5] select 4th and 5th value in a list;
- [start (inclusive) : end (exclusive)]
- [:4] select from 0 to 5th value;
- Manipulating Lists:
- Adding and removing elements:
- height + ["me", 1.79]
- del(height[2])
- Numpy: allows for calculations of python list;
- Python does not know how to do calculation of list;
- Numpy array calculation is different to python list;
- np.array(list)
-
-
- np.array([1d], [2d]);
- Array can only contain the same type;
- np_2d[row][col] = np_2d[row,col];
- np_2d[:, 1:3] = all rows and collumn 1 to 3
import numpy as np
x = np.array([19, 2, 13, 4])
print(x[0:3])
Output = [19 2 13]
-
- Basic statistics:
np.mean()
np.median()
np.std()
np.corrcoef()
- Introduction of Python - Variable and Types
Variables:
- Reference the value of the actual variable;
- Variable can be used for calculation;
Type:
- type();
- Strings and booleans are common data types;
- float;
- int;
- str;
- bool;