| Function | Description |
|---|---|
| abs, fabs | Compute the absolute value element-wise for integer, floating point, or complex values. |
| Use fabs as a faster alternative for non-complex-valued data | |
| sqrt | Compute the square root of each element. Equivalent to arr ** 0.5 |
| square | Compute the square of each element. Equivalent to arr ** 2 |
| exp | Compute the exponent ex of each element |
| log, log10, log2, log1p | Natural logarithm (base e), log base 10, log base 2, and log(1 + x), respectively |
| sign | Compute the sign of each element: 1 (positive), 0 (zero), or -1 (negative) |
| ceil | Compute the ceiling of each element, i.e. the smallest integer greater than or equal to each element |
| Function | Description |
|---|---|
| unique(x) | Compute the sorted, unique elements in x |
| intersect1d(x, y) | Compute the sorted, common elements in x and y |
| union1d(x, y) | Compute the sorted union of elements |
| in1d(x, y) | Compute a boolean array indicating whether each element of x is contained in y |
| setdiff1d(x, y) | Set difference, elements in x that are not in y |
| setxor1d(x, y) | Set symmetric differences; elements that are in either of the arrays, but not both |
|iPython System Commands| |:---|:---| |!cmd |Execute cmd in the system shell | |output = !cmd args |Run cmd and store the stdout in output | |%alias alias_name cmd |Define an alias for a system (shell) command| |%bookmark |Utilize IPython’s directory bookmarking system | |%cd directory |Change system working directory to passed directory | |%pwd |Return the current system working directory | |%pushd directory |Place current directory on stack and change to target directory | |%popd |Change to directory popped off the top of the stack |
| Shortcut | Description |
|---|---|
| Ctrl-P or up-arrow | Search backward in command history for commands starting with currently-entered text |
| Ctrl-N or down-arrow | Search forward in command history for commands starting with currently-entered text |
| Ctrl-R | Readline-style reverse history search (partial matching) |
| Ctrl-Shift-V | Paste text from clipboard |
| Ctrl-C | Interrupt currently-executing code |
| Ctrl-A | Move cursor to beginning of line |
| Ctrl-E | Move cursor to end of line |
| Ctrl-K | Delete text from cursor until end of line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import pandas as pd | |
| from sklearn.linear_model import LinearRegression | |
| data = pd.read_csv('data.csv') | |
| X = data.iloc[:, 0].values.reshape(-1, 1) # values converts it into a numpy array | |
| Y = data.iloc[:, 1].values.reshape(-1, 1) # -1 means that calculate the dimension of rows, but have 1 column | |
| linear_regressor = LinearRegression() | |
| linear_regressor.fit(X, Y) # perform linear regression |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # generate a 10MB file named `testfile` filled with random stuff | |
| dd if=/dev/urandom of=testfile bs=1000000 count=10 |
OlderNewer