Reference / 40 entries
The functions you will reach for most.
Signatures, parameters, working examples, and the mistakes that usually follow. Search across every track or narrow the list to the library you are using.
40 results
- NumPynumpy
np.array
Create an array from a Python sequence or another array.
np.array(object, dtype=None, copy=True) - NumPynumpy
np.zeros
Create an array filled with zeros.
np.zeros(shape, dtype=float) - NumPynumpy
np.arange
Create evenly spaced values within a half-open interval.
np.arange(start, stop=None, step=1, dtype=None) - NumPynumpy
np.linspace
Create a chosen number of evenly spaced points.
np.linspace(start, stop, num=50, endpoint=True) - NumPynumpy
ndarray.reshape
Return an array with the same data arranged in a new shape.
ndarray.reshape(shape, order='C') - NumPynumpy
np.sum
Add values across an array or along one axis.
np.sum(a, axis=None, keepdims=False, dtype=None) - NumPynumpy
np.mean
Compute the arithmetic mean along an axis.
np.mean(a, axis=None, keepdims=False, dtype=None) - NumPynumpy
np.where
Choose values by condition or return matching indices.
np.where(condition, x=None, y=None) - NumPynumpy
np.random.default_rng
Create a reproducible random number generator.
np.random.default_rng(seed=None) - NumPynumpy
np.linalg.solve
Solve a square linear system a @ x = b.
np.linalg.solve(a, b) - NumPynumpy
np.clip
Limit every value in an array to a fixed range.
np.clip(a, a_min, a_max) - NumPynumpy
np.concatenate
Join arrays along an existing axis.
np.concatenate((a1, a2, ...), axis=0) - NumPynumpy
np.argmax
Return the index of the largest value.
np.argmax(a, axis=None) - NumPynumpy
np.percentile
Compute a percentile of the values in an array.
np.percentile(a, q, axis=None) - NumPynumpy
np.linalg.norm
Measure the length of a vector or matrix.
np.linalg.norm(x, ord=None, axis=None) - pandaspandas
pd.DataFrame
Build a two-dimensional labeled table.
pd.DataFrame(data=None, index=None, columns=None) - pandaspandas
pd.read_csv
Load a comma-separated file into a DataFrame.
pd.read_csv(filepath_or_buffer, sep=',', header='infer') - pandaspandas
DataFrame.head
Return the first rows of a DataFrame or Series.
DataFrame.head(n=5) - pandaspandas
DataFrame.loc
Select rows and columns by label.
DataFrame.loc[row_indexer, column_indexer] - pandaspandas
DataFrame.groupby
Split rows into groups for aggregation.
DataFrame.groupby(by, as_index=True) - pandaspandas
DataFrame.merge
Combine two DataFrames on shared keys.
DataFrame.merge(right, how='inner', on=None) - pandaspandas
DataFrame.fillna
Replace missing values with a constant or computed value.
DataFrame.fillna(value=None, *, method=None, axis=None, inplace=False) - pandaspandas
pd.cut
Bin continuous values into discrete intervals.
pd.cut(x, bins, right=True, labels=None) - pandaspandas
DataFrame.astype
Convert columns to another dtype.
DataFrame.astype(dtype, copy=True) - pandaspandas
Series.value_counts
Count how often each value appears.
Series.value_counts(normalize=False, sort=True, dropna=True) - pandaspandas
pd.get_dummies
Create indicator columns for categorical values.
pd.get_dummies(data, columns=None, drop_first=False, dtype=None) - Matplotlibmatplotlib
plt.subplots
Create a figure and one or more axes in one call.
plt.subplots(nrows=1, ncols=1, figsize=None, sharex=False, sharey=False) - Matplotlibmatplotlib
Axes.plot
Draw lines and markers on an axes.
Axes.plot(*args, label=None, color=None) - Matplotlibmatplotlib
Axes.set
Set common axes labels, title, and limits in one call.
Axes.set(xlabel=None, ylabel=None, title=None, xlim=None, ylim=None) - Matplotlibmatplotlib
Axes.legend
Show a legend for labeled artists.
Axes.legend(loc='best', frameon=True) - Matplotlibmatplotlib
Figure.savefig
Write a figure to an image file.
Figure.savefig(fname, dpi='figure', bbox_inches=None) - Matplotlibmatplotlib
ConfusionMatrixDisplay
Draw a labeled confusion matrix from scikit-learn output.
ConfusionMatrixDisplay(confusion_matrix, display_labels=None) - Matplotlibmatplotlib
RocCurveDisplay
Plot a ROC curve directly from a fitted classifier.
RocCurveDisplay.from_estimator(estimator, X, y) - Matplotlibmatplotlib
PrecisionRecallDisplay
Plot precision against recall for a binary classifier.
PrecisionRecallDisplay.from_estimator(estimator, X, y) - Matplotlibmatplotlib
LearningCurveDisplay
Plot training and validation scores as training size grows.
LearningCurveDisplay.from_estimator(estimator, X, y, cv=5) - scikit-learnsklearn
train_test_split
Split arrays into training and test subsets.
train_test_split(*arrays, test_size=None, random_state=None, stratify=None) - scikit-learnsklearn
StandardScaler
Center features and scale them to unit variance.
StandardScaler(*, with_mean=True, with_std=True) - scikit-learnsklearn
LinearRegression
Fit an ordinary least-squares regression model.
LinearRegression(*, fit_intercept=True) - scikit-learnsklearn
accuracy_score
Measure the fraction of correctly classified rows.
accuracy_score(y_true, y_pred, normalize=True) - scikit-learnsklearn
Pipeline
Chain preprocessing and a model into one estimator.
Pipeline(steps)