From 25e2986816b6cb71b7c2804b3a1bb9d8cd87c446 Mon Sep 17 00:00:00 2001 From: Asabeneh Date: Thu, 12 Dec 2019 23:59:37 +0200 Subject: [PATCH] day 24 --- numpy.ipynb | 2072 +++++++++++++++++++++++++++++++++++ numpy.md | 1675 ++++++++++++++++++++++++++++ numpy_files/numpy_108_1.png | Bin 0 -> 5096 bytes numpy_files/numpy_122_0.png | Bin 0 -> 12639 bytes numpy_files/numpy_123_1.png | Bin 0 -> 11080 bytes readme19-21.md | 2 +- readme22-24.md | 1101 ++++++++++++++++++- 7 files changed, 4836 insertions(+), 14 deletions(-) create mode 100644 numpy.ipynb create mode 100644 numpy.md create mode 100644 numpy_files/numpy_108_1.png create mode 100644 numpy_files/numpy_122_0.png create mode 100644 numpy_files/numpy_123_1.png diff --git a/numpy.ipynb b/numpy.ipynb new file mode 100644 index 00000000..a085242d --- /dev/null +++ b/numpy.ipynb @@ -0,0 +1,2072 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "###### Author: Asabeneh Yetayeh\n", + "\n", + "# Numpy(Numberic Python)\n", + "\n", + "In this note book you will cover all what you need to know about Numpy. Inditon to numpy we will see how to use matplot lib python library which will help us to draw graphs and visualize data.\n", + "\n", + "So far, we have been using vscode but from now on I would recommend using Jupter Notebook. To access jupter notebook let's install [anaconda](https://www.anaconda.com/)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "# Installation anconda numpy" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## How to import numpy (Numeric Python)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "# A numpy array must have all items to be of the same data type, unlike lists.\n", + "# This is another significant difference." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "# How to import numpy\n", + "import numpy as np\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## How to check package version in python" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "numpy: 1.17.2\n" + } + ], + "source": [ + "# How to check the version of the numpy package\n", + "print('numpy:', np.__version__)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "['ALLOW_THREADS', 'AxisError', 'BUFSIZE', 'CLIP', 'ComplexWarning', 'DataSource', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'False_', 'Inf', 'Infinity', 'MAXDIMS', 'MAY_SHARE_BOUNDS', 'MAY_SHARE_EXACT', 'MachAr', 'ModuleDeprecationWarning', 'NAN', 'NINF', 'NZERO', 'NaN', 'PINF', 'PZERO', 'RAISE', 'RankWarning', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID', 'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'ScalarType', 'Tester', 'TooHardError', 'True_', 'UFUNC_BUFSIZE_DEFAULT', 'UFUNC_PYVALS_NAME', 'VisibleDeprecationWarning', 'WRAP', '_NoValue', '_UFUNC_API', '__NUMPY_SETUP__', '__all__', '__builtins__', '__cached__', '__config__', '__doc__', '__file__', '__git_revision__', '__loader__', '__mkl_version__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_add_newdoc_ufunc', '_distributor_init', '_globals', '_mat', '_pytesttester', 'abs', 'absolute', 'absolute_import', 'add', 'add_docstring', 'add_newdoc', 'add_newdoc_ufunc', 'alen', 'all', 'allclose', 'alltrue', 'amax', 'amin', 'angle', 'any', 'append', 'apply_along_axis', 'apply_over_axes', 'arange', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh', 'argmax', 'argmin', 'argpartition', 'argsort', 'argwhere', 'around', 'array', 'array2string', 'array_equal', 'array_equiv', 'array_repr', 'array_split', 'array_str', 'asanyarray', 'asarray', 'asarray_chkfinite', 'ascontiguousarray', 'asfarray', 'asfortranarray', 'asmatrix', 'asscalar', 'atleast_1d', 'atleast_2d', 'atleast_3d', 'average', 'bartlett', 'base_repr', 'binary_repr', 'bincount', 'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'blackman', 'block', 'bmat', 'bool', 'bool8', 'bool_', 'broadcast', 'broadcast_arrays', 'broadcast_to', 'busday_count', 'busday_offset', 'busdaycalendar', 'byte', 'byte_bounds', 'bytes0', 'bytes_', 'c_', 'can_cast', 'cast', 'cbrt', 'cdouble', 'ceil', 'cfloat', 'char', 'character', 'chararray', 'choose', 'clip', 'clongdouble', 'clongfloat', 'column_stack', 'common_type', 'compare_chararrays', 'compat', 'complex', 'complex128', 'complex256', 'complex64', 'complex_', 'complexfloating', 'compress', 'concatenate', 'conj', 'conjugate', 'convolve', 'copy', 'copysign', 'copyto', 'core', 'corrcoef', 'correlate', 'cos', 'cosh', 'count_nonzero', 'cov', 'cross', 'csingle', 'ctypeslib', 'cumprod', 'cumproduct', 'cumsum', 'datetime64', 'datetime_as_string', 'datetime_data', 'deg2rad', 'degrees', 'delete', 'deprecate', 'deprecate_with_doc', 'diag', 'diag_indices', 'diag_indices_from', 'diagflat', 'diagonal', 'diff', 'digitize', 'disp', 'divide', 'division', 'divmod', 'dot', 'double', 'dsplit', 'dstack', 'dtype', 'e', 'ediff1d', 'einsum', 'einsum_path', 'emath', 'empty', 'empty_like', 'equal', 'errstate', 'euler_gamma', 'exp', 'exp2', 'expand_dims', 'expm1', 'extract', 'eye', 'fabs', 'fastCopyAndTranspose', 'fft', 'fill_diagonal', 'find_common_type', 'finfo', 'fix', 'flatiter', 'flatnonzero', 'flexible', 'flip', 'fliplr', 'flipud', 'float', 'float128', 'float16', 'float32', 'float64', 'float_', 'float_power', 'floating', 'floor', 'floor_divide', 'fmax', 'fmin', 'fmod', 'format_float_positional', 'format_float_scientific', 'format_parser', 'frexp', 'frombuffer', 'fromfile', 'fromfunction', 'fromiter', 'frompyfunc', 'fromregex', 'fromstring', 'full', 'full_like', 'fv', 'gcd', 'generic', 'genfromtxt', 'geomspace', 'get_array_wrap', 'get_include', 'get_printoptions', 'getbufsize', 'geterr', 'geterrcall', 'geterrobj', 'gradient', 'greater', 'greater_equal', 'half', 'hamming', 'hanning', 'heaviside', 'histogram', 'histogram2d', 'histogram_bin_edges', 'histogramdd', 'hsplit', 'hstack', 'hypot', 'i0', 'identity', 'iinfo', 'imag', 'in1d', 'index_exp', 'indices', 'inexact', 'inf', 'info', 'infty', 'inner', 'insert', 'int', 'int0', 'int16', 'int32', 'int64', 'int8', 'int_', 'int_asbuffer', 'intc', 'integer', 'interp', 'intersect1d', 'intp', 'invert', 'ipmt', 'irr', 'is_busday', 'isclose', 'iscomplex', 'iscomplexobj', 'isfinite', 'isfortran', 'isin', 'isinf', 'isnan', 'isnat', 'isneginf', 'isposinf', 'isreal', 'isrealobj', 'isscalar', 'issctype', 'issubclass_', 'issubdtype', 'issubsctype', 'iterable', 'ix_', 'kaiser', 'kron', 'lcm', 'ldexp', 'left_shift', 'less', 'less_equal', 'lexsort', 'lib', 'linalg', 'linspace', 'little_endian', 'load', 'loads', 'loadtxt', 'log', 'log10', 'log1p', 'log2', 'logaddexp', 'logaddexp2', 'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'logspace', 'long', 'longcomplex', 'longdouble', 'longfloat', 'longlong', 'lookfor', 'ma', 'mafromtxt', 'mask_indices', 'mat', 'math', 'matmul', 'matrix', 'matrixlib', 'max', 'maximum', 'maximum_sctype', 'may_share_memory', 'mean', 'median', 'memmap', 'meshgrid', 'mgrid', 'min', 'min_scalar_type', 'minimum', 'mintypecode', 'mirr', 'mkl', 'mod', 'modf', 'moveaxis', 'msort', 'multiply', 'nan', 'nan_to_num', 'nanargmax', 'nanargmin', 'nancumprod', 'nancumsum', 'nanmax', 'nanmean', 'nanmedian', 'nanmin', 'nanpercentile', 'nanprod', 'nanquantile', 'nanstd', 'nansum', 'nanvar', 'nbytes', 'ndarray', 'ndenumerate', 'ndfromtxt', 'ndim', 'ndindex', 'nditer', 'negative', 'nested_iters', 'newaxis', 'nextafter', 'nonzero', 'not_equal', 'nper', 'npv', 'numarray', 'number', 'obj2sctype', 'object', 'object0', 'object_', 'ogrid', 'oldnumeric', 'ones', 'ones_like', 'os', 'outer', 'packbits', 'pad', 'partition', 'percentile', 'pi', 'piecewise', 'place', 'pmt', 'poly', 'poly1d', 'polyadd', 'polyder', 'polydiv', 'polyfit', 'polyint', 'polymul', 'polynomial', 'polysub', 'polyval', 'positive', 'power', 'ppmt', 'print_function', 'printoptions', 'prod', 'product', 'promote_types', 'ptp', 'put', 'put_along_axis', 'putmask', 'pv', 'quantile', 'r_', 'rad2deg', 'radians', 'random', 'rank', 'rate', 'ravel', 'ravel_multi_index', 'real', 'real_if_close', 'rec', 'recarray', 'recfromcsv', 'recfromtxt', 'reciprocal', 'record', 'remainder', 'repeat', 'require', 'reshape', 'resize', 'result_type', 'right_shift', 'rint', 'roll', 'rollaxis', 'roots', 'rot90', 'round', 'round_', 'row_stack', 's_', 'safe_eval', 'save', 'savetxt', 'savez', 'savez_compressed', 'sctype2char', 'sctypeDict', 'sctypeNA', 'sctypes', 'searchsorted', 'select', 'set_numeric_ops', 'set_printoptions', 'set_string_function', 'setbufsize', 'setdiff1d', 'seterr', 'seterrcall', 'seterrobj', 'setxor1d', 'shape', 'shares_memory', 'short', 'show_config', 'sign', 'signbit', 'signedinteger', 'sin', 'sinc', 'single', 'singlecomplex', 'sinh', 'size', 'sometrue', 'sort', 'sort_complex', 'source', 'spacing', 'split', 'sqrt', 'square', 'squeeze', 'stack', 'std', 'str', 'str0', 'str_', 'string_', 'subtract', 'sum', 'swapaxes', 'sys', 'take', 'take_along_axis', 'tan', 'tanh', 'tensordot', 'test', 'testing', 'tile', 'timedelta64', 'trace', 'tracemalloc_domain', 'transpose', 'trapz', 'tri', 'tril', 'tril_indices', 'tril_indices_from', 'trim_zeros', 'triu', 'triu_indices', 'triu_indices_from', 'true_divide', 'trunc', 'typeDict', 'typeNA', 'typecodes', 'typename', 'ubyte', 'ufunc', 'uint', 'uint0', 'uint16', 'uint32', 'uint64', 'uint8', 'uintc', 'uintp', 'ulonglong', 'unicode', 'unicode_', 'union1d', 'unique', 'unpackbits', 'unravel_index', 'unsignedinteger', 'unwrap', 'ushort', 'vander', 'var', 'vdot', 'vectorize', 'version', 'void', 'void0', 'vsplit', 'vstack', 'warnings', 'where', 'who', 'zeros', 'zeros_like']\n" + } + ], + "source": [ + "# Checking the available methods\n", + "print(dir(np))" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "0.3010299956639812\nFalse\n" + } + ], + "source": [ + "print(np.log10(2))\n", + "print(np.not_equal(10, 10))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Creating a list in python" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "\n[1, 2, 3, 4, 5]\n[[0, 1, 2], [3, 4, 5], [6, 7, 8]]\n" + } + ], + "source": [ + "# Creating python List\n", + "\n", + "python_list = [1,2,3,4,5]\n", + "# Checking data types\n", + "print(type (python_list))\n", + "print(python_list)\n", + "two_dimensional_list = [[0,1,2], [3,4,5], [6,7,8]]\n", + "print(two_dimensional_list)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Creating numpy array using numpy" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "\n[1 2 3 4 5]\n" + } + ], + "source": [ + "# Creating Numpy(Numerical Python) array from python list\n", + "numpy_array_from_list = np.array(python_list)\n", + "print(type (numpy_array_from_list))\n", + "print(numpy_array_from_list)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([1, 2, 3, 4, 5])" + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "numy_array_from_list2 = np.array(python_list)\n", + "numy_array_from_list2" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([1., 2., 3., 4., 5.])" + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "numy_array_from_list2 = np.array(python_list, dtype=float)\n", + "numy_array_from_list2" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([False, True, True, False, False])" + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "numpy_bool_array = np.array([0, 1, -1, 0, 0], dtype=bool)\n", + "numpy_bool_array" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "\n[[0 1 2]\n [3 4 5]\n [6 7 8]]\n" + } + ], + "source": [ + "\n", + "numpy_two_dimensional_list = np.array(two_dimensional_list)\n", + "print(type (numpy_two_dimensional_list))\n", + "print(numpy_two_dimensional_list)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([1, 2, 3, 4, 5])" + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "numpy_array_from_list" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[0, 1, 2],\n [3, 4, 5],\n [6, 7, 8]])" + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "numpy_two_dimensional_list" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Converting numpy array to list" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "\none dimensional array: [1, 2, 3, 4, 5]\ntwo dimensional array: [[0, 1, 2], [3, 4, 5], [6, 7, 8]]\n" + } + ], + "source": [ + "# We can always convert an array back to a python list using tolist().\n", + "np_to_list = numpy_array_from_list.tolist()\n", + "print(type (np_to_list))\n", + "print('one dimensional array:', np_to_list)\n", + "print('two dimensional array: ', numpy_two_dimensional_list.tolist())" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[0, 1, 2],\n [3, 4, 5],\n [6, 7, 8]])" + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "numpy_two_dimensional_list" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Creating numpy array from tuple" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "\npython_tuple: (1, 2, 3, 4, 5)\n\nnumpy_array_from_tuple: [1 2 3 4 5]\n" + } + ], + "source": [ + "# Numpy array from tuple\n", + "\n", + "# Creating tuple in Python\n", + "\n", + "python_tuple = (1,2,3,4,5)\n", + "print(type (python_tuple))\n", + "print('python_tuple: ', python_tuple)\n", + "\n", + "numpy_array_from_tuple = np.array(python_tuple)\n", + "print(type (numpy_array_from_tuple))\n", + "print('numpy_array_from_tuple: ', numpy_array_from_tuple)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([1, 2, 3, 4, 5])" + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "numpy_array_from_tuple" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Shape of numpy array\n", + "The shape method provide the shape of the array as a tuple. The first is the row and the second is the column" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "[1 2 3 4 5]\nshape of nums: (5,)\n[[0 1 2]\n [3 4 5]\n [6 7 8]]\nshape of numpy_two_dimensional_list: (3, 3)\n(3, 4)\n" + } + ], + "source": [ + "nums = np.array([1, 2, 3, 4, 5])\n", + "print(nums)\n", + "print('shape of nums: ', nums.shape)\n", + "print(numpy_two_dimensional_list)\n", + "print('shape of numpy_two_dimensional_list: ', numpy_two_dimensional_list.shape)\n", + "three_by_four_array = np.array([[0, 1, 2, 3],\n", + " [4,5,6,7],\n", + " [8,9,10, 11]])\n", + "print(three_by_four_array.shape)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Data type of numpy array\n", + "\n", + "Type of data types: str, int, float, complex, bool, list, None" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "[-3 -2 -1 0 1 2 3]\nint64\n[-3. -2. -1. 0. 1. 2. 3.]\nfloat64\n" + } + ], + "source": [ + "int_lists = [-3, -2, -1, 0, 1, 2,3]\n", + "int_array = np.array(int_lists)\n", + "float_array = np.array(int_lists, dtype=float)\n", + "\n", + "print(int_array)\n", + "print(int_array.dtype)\n", + "print(float_array)\n", + "print(float_array.dtype)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Size of a numpy array\n", + "Instead of len size is used to get the length of items in a numpy array" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "5" + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "numpy_array_from_list.size" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "9" + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "numpy_two_dimensional_list.size" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Mathematical Operation\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "original array: [1 2 3 4 5]\n[11 12 13 14 15]\n[-9 -8 -7 -6 -5]\n[10 20 30 40 50]\n" + } + ], + "source": [ + "# Mathematical Operation\n", + "\n", + "# Addition\n", + "print('original array: ', numpy_array_from_list)\n", + "ten_plus_original = numpy_array_from_list + 10\n", + "print(ten_plus_original)\n", + "ten_minus_original = numpy_array_from_list - 10\n", + "print(ten_minus_original)\n", + "# Multiplication\n", + "ten_times_original = numpy_array_from_list * 10\n", + "print(ten_times_original)" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "int64\nfloat64\nfloat64\n" + } + ], + "source": [ + "# Float numbers\n", + "\n", + "numpy_int_list = np.array([1,2,3,4])\n", + "numpy_float_list = np.array([1.1, 2.0,3.2])\n", + "numpy_float_list2 = np.array([1.1,2.0,3.2])\n", + "\n", + "print(numpy_int_list.dtype)\n", + "print(numpy_float_list2.dtype)\n", + "print(numpy_float_list.dtype)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Converting type from float to int" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([1, 2, 3])" + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Converting type from float to int\n", + "numpy_float_list.astype('int')\n" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array(['1', '2', '3'], dtype='\n[[1 2 3]\n [4 5 6]\n [7 8 9]]\nShape: (3, 3)\nSize: 9\nData type: int64\n" + } + ], + "source": [ + "# 2 Dimension Array\n", + "two_dimension_array = np.array([(1,2,3),(4,5,6), (7,8,9)])\n", + "print(type (two_dimension_array))\n", + "print(two_dimension_array)\n", + "print('Shape: ', two_dimension_array.shape)\n", + "print('Size:', two_dimension_array.size)\n", + "print('Data type:', two_dimension_array.dtype)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[1, 2, 3],\n [4, 5, 6],\n [7, 8, 9]])" + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "two_dimension_array" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## How to extract specific items from an array?" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "First row: [1 2 3]\nSecond row: [4 5 6]\nThird row: [7 8 9]\n" + } + ], + "source": [ + "first_row = two_dimension_array[0]\n", + "second_row = two_dimension_array[1]\n", + "third_row = two_dimension_array[2]\n", + "print('First row:', first_row)\n", + "print('Second row:', second_row)\n", + "print('Third row: ', third_row)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "First column: [1 4 7]\nSecond column: [2 5 8]\nThird column: [3 6 9]\n[[1 2 3]\n [4 5 6]\n [7 8 9]]\n" + } + ], + "source": [ + "first_column= two_dimension_array[:,0]\n", + "second_column = two_dimension_array[:,1]\n", + "third_column = two_dimension_array[:,2]\n", + "print('First column:', first_column)\n", + "print('Second column:', second_column)\n", + "print('Third column: ', third_column)\n", + "print(two_dimension_array)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Slicing in numpy is similar to list" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[1, 2],\n [4, 5]])" + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "first_two_rows_and_columns = two_dimension_array[0:2, 0:2]\n", + "first_two_rows_and_columns" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## How to reverse the rows and the whole array?" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[1, 2, 3],\n [4, 5, 6],\n [7, 8, 9]])" + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "two_dimension_array[::]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Reverse only the row positions" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[7, 8, 9],\n [4, 5, 6],\n [1, 2, 3]])" + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "two_dimension_array[::-1,]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Reverse the row and column positions" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[9, 8, 7],\n [6, 5, 4],\n [3, 2, 1]])" + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "two_dimension_array[::-1,::-1]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## How to represent missing values and infinite?" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "[[1 2 3]\n [4 5 6]\n [7 8 9]]\n[[ 1 2 3]\n [ 4 55 44]\n [ 7 8 9]]\n" + } + ], + "source": [ + "print(two_dimension_array)\n", + "two_dimension_array[1,1] = 55\n", + "two_dimension_array[1,2] =44\n", + "print(two_dimension_array)" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[0, 0, 0],\n [0, 0, 0],\n [0, 0, 0]])" + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Numpy Zeroes\n", + "# numpy.zeros(shape, dtype=float, order='C')\n", + "numpy_zeroes = np.zeros((3,3),dtype=int,order='C')\n", + "numpy_zeroes" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "[[1 1 1]\n [1 1 1]\n [1 1 1]]\n" + } + ], + "source": [ + "# Numpy Zeroes\n", + "numpy_ones = np.ones((3,3),dtype=int,order='C')\n", + "print(numpy_ones)" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [], + "source": [ + "twoes = numpy_ones * 2" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "[[1 2 3]\n [4 5 6]]\n[[1 2]\n [3 4]\n [5 6]]\n" + } + ], + "source": [ + "# Reshape\n", + "# numpy.reshape(), numpy.flatten()\n", + "first_shape = np.array([(1,2,3), (4,5,6)])\n", + "print(first_shape)\n", + "reshaped = first_shape.reshape(3,2)\n", + "print(reshaped)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([1, 2, 3, 4, 5, 6])" + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "flattened = reshaped.flatten()\n", + "flattened" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "[5 7 9]\nHorizontal Append: [1 2 3 4 5 6]\n" + } + ], + "source": [ + "## Horitzontal Stack\n", + "np_list_one = np.array([1,2,3])\n", + "np_list_two = np.array([4,5,6])\n", + "\n", + "print(np_list_one + np_list_two)\n", + "\n", + "print('Horizontal Append:', np.hstack((np_list_one, np_list_two)))" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "Vertical Append: [[1 2 3]\n [4 5 6]]\n" + } + ], + "source": [ + "## Vertical Stack\n", + "print('Vertical Append:', np.vstack((np_list_one, np_list_two)))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Generating Random Numbers" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "0.1477747854886351" + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Generate a random float number\n", + "random_float = np.random.random()\n", + "random_float" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([0.66880516, 0.58036922, 0.32565217, 0.75833764, 0.33492522])" + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Generate a random float number\n", + "random_floats = np.random.random(5)\n", + "random_floats" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "1" + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Generating a random integers between 0 and 10\n", + "random_int = np.random.randint(0, 11)\n", + "random_int" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([6, 7, 6, 5])" + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Generating a random integers between 2 and 11, and creating a one row array\n", + "random_int = np.random.randint(2,10, size=4)\n", + "random_int" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[4, 8, 7],\n [6, 3, 8],\n [8, 3, 4]])" + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Generating a random integers between 0 and 10\n", + "random_int = np.random.randint(2,10, size=(3,3))\n", + "random_int" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([ 78.06228226, 80.47997605, 67.16871012, 100.01106251,\n 73.43427077, 70.90858509, 68.18228819, 88.71233066,\n 86.23943257, 99.66232512, 80.46786746, 105.15418964,\n 78.37084644, 74.10533462, 81.86581832, 78.34056027,\n 72.13209789, 72.69912968, 111.64843341, 96.02940931,\n 80.82983836, 49.2603406 , 82.11783362, 82.00473287,\n 68.36971774, 83.44601599, 75.22668092, 67.16102449,\n 84.12544108, 84.89425903, 69.87305909, 96.80967774,\n 80.89504255, 33.82173197, 65.9476567 , 114.69465093,\n 87.58440669, 59.44914567, 69.09711011, 81.28734677,\n 54.02167729, 76.24325763, 81.07595137, 78.25321296,\n 56.06354536, 74.88790644, 65.37671466, 73.0608308 ,\n 83.53329124, 56.11613468, 69.70534252, 105.03153668,\n 92.09774157, 76.27471759, 66.30470031, 75.26872422,\n 104.47856237, 69.43495655, 78.47940174, 66.33033948,\n 88.47445255, 53.07577185, 106.87650496, 84.80340513,\n 92.70276459, 66.26854244, 92.80079253, 90.54206113,\n 76.68091973, 88.37271982, 99.28200027, 85.85283546,\n 81.3903595 , 64.08758723, 56.9362159 , 51.233451 ,\n 72.95037141, 81.21256832, 95.22519781, 69.18242214,\n 47.90222857, 87.08328607, 80.42971413, 94.36731459,\n 52.62876844, 65.72917254, 62.00665453, 60.2468513 ,\n 89.17802841, 95.21163386, 87.46425376, 110.2230449 ,\n 72.34068564, 69.43244175, 79.42739361, 91.96167318,\n 88.71546515, 46.20839431, 93.30432944, 83.55539894,\n 88.63548129, 73.50049682, 59.96380522, 93.58951555,\n 120.13068226, 70.06924206, 65.69839628, 83.23774129,\n 79.25570985, 71.89321258, 80.64905645, 76.07107192,\n 89.34416292, 98.82861126, 73.4790967 , 63.35301086,\n 83.76185379, 100.64189068, 70.13596249, 64.50577384,\n 75.04897329, 78.99902225, 85.14751918, 69.71124641,\n 65.90879778, 90.30143113, 104.27014623, 84.86204287,\n 74.41819024, 62.6483838 , 90.39531176, 52.18361377,\n 56.10889369, 105.07634101, 74.60664275, 80.48560286,\n 93.92703692, 89.4721985 , 76.69992387, 87.55989167,\n 74.42497904, 93.34549716, 85.56512669, 91.27006247,\n 76.99063702, 74.51895242, 68.31335173, 61.82950247,\n 74.27565476, 75.47967285, 56.99448404, 77.83995971,\n 88.23766005, 64.25073627, 84.21727063, 72.73365378,\n 90.56998368, 61.90746621, 104.32735616, 33.51801517,\n 38.17830252, 91.00363097, 79.96743202, 92.59940851,\n 74.31161094, 78.25334346, 87.49652045, 65.10876645,\n 97.29702422, 71.21703521, 71.57154296, 55.67862433,\n 78.63567388, 77.39172292, 85.85382211, 76.1303165 ,\n 79.93907903, 55.86163862, 65.03007833, 98.06472484,\n 98.18297161, 86.35617188, 73.95928996, 81.58243288,\n 72.13009418, 85.57473551, 73.31333927, 90.54931228,\n 92.84532205, 84.5451769 , 86.73824099, 84.29718499,\n 108.54889407, 82.05896086, 64.74466701, 87.31905746,\n 70.86189615, 74.17689346, 98.68855732, 73.47579279,\n 112.8709868 , 73.95676101, 62.34891052, 89.75718241,\n 86.84831209, 84.76483197, 75.00712483, 89.66930311,\n 79.02327324, 111.2672887 , 65.93375863, 57.32720674,\n 55.36834689, 80.69909018, 96.25708549, 86.41302494,\n 106.71440179, 87.34716208, 53.87588225, 67.60260121,\n 71.74959277, 69.64175761, 61.62553359, 92.84685364,\n 88.39326749, 67.82375745, 78.88508202, 63.41683055,\n 83.33247265, 61.78182943, 69.47178609, 94.29415174,\n 71.34896978, 42.97502617, 94.36712783, 66.99952686,\n 71.18875098, 61.51192175, 58.25951442, 67.83145087,\n 93.1965335 , 78.841944 , 90.02731255, 108.67011039,\n 87.9282376 , 62.27183736, 84.46821305, 93.10995068,\n 81.79071208, 40.0635728 , 102.20724488, 88.6488238 ,\n 92.91848738, 93.32901714, 74.89123998, 102.44537103,\n 58.84904865, 80.17557578, 69.60840343, 65.11810179,\n 73.57184954, 103.42197477, 94.51878907, 76.34101893,\n 58.20236603, 76.15803306, 85.01092471, 102.62825199,\n 70.57778869, 64.55384487, 75.92847535, 108.29656951,\n 65.09564337, 71.97746096, 67.91685793, 98.37480773,\n 78.55584328, 58.79508008, 83.78716705, 85.51819492,\n 85.39472497, 86.48911498, 86.74878694, 88.82191939,\n 87.56668016, 68.18363072, 72.65452689, 86.89008749,\n 74.10734973, 55.4094851 , 66.84354188, 58.51715121,\n 90.78804647, 66.26231617, 83.23663878, 121.92253573,\n 94.17040645, 85.300603 , 83.28102031, 88.92437677,\n 47.92432906, 74.9123454 , 74.82372863, 102.34755849,\n 63.97023146, 91.42597585, 76.97286274, 89.99561505,\n 104.27334052, 65.28530687, 71.76722311, 76.99942849,\n 93.12862908, 88.29252813, 74.40020522, 59.83777803,\n 86.2692467 , 57.72956079, 92.21270412, 76.32248068,\n 74.39526899, 54.8414521 , 48.888437 , 106.77555705,\n 104.07932258, 62.61412927, 91.17935874, 69.99817706,\n 80.27041286, 85.57510819, 87.32432908, 94.01658731,\n 87.54240264, 68.81017962, 91.37078862, 82.47632639,\n 97.58252432, 87.48121013, 74.6234212 , 74.6986795 ,\n 76.65946615, 74.36683032, 86.98593152, 54.16182721,\n 95.90072974, 68.90556443, 88.8115489 , 61.33034803,\n 75.03376482, 85.67012786, 69.61414988, 77.9329127 ,\n 74.73350745, 50.98154773, 70.32859405, 81.82842611,\n 79.34651799, 56.61456886, 108.10555204, 88.22287037,\n 74.39100199, 76.41366393, 62.04351567, 83.27601537,\n 86.99514943, 71.91082253, 64.87485275, 95.53195338,\n 75.98938226, 50.46800926, 99.48823496, 87.43692335,\n 77.78589128, 70.70840352, 103.66404784, 98.84563267,\n 83.84939092, 63.35894729, 86.21033577, 113.4329368 ,\n 71.96158217, 85.28699953, 58.00992511, 79.71669981,\n 89.32418303, 39.37997338, 86.20379324, 65.66118568,\n 78.98887722, 116.59556808, 96.71728972, 62.82439269,\n 81.48105406, 50.10899439, 85.05778363, 75.00743273,\n 91.94666309, 56.79855211, 63.95730649, 62.68945327,\n 85.85109342, 83.27385995, 83.27264177, 73.24183525,\n 56.87217993, 68.80304416, 91.42472878, 96.91813936,\n 61.43286456, 60.19787993, 76.10324428, 76.02346429,\n 70.30878903, 111.39327281, 83.58888893, 100.87217758,\n 86.65284275, 80.57122349, 84.30929287, 83.29940119,\n 77.22425347, 83.70996324, 76.18292731, 70.66577399,\n 82.87365549, 60.97611143, 84.00291165, 73.75303205,\n 62.36634484, 81.03059977, 78.79641201, 66.80902035,\n 68.81283634, 95.40175522, 100.9812039 , 87.22874071,\n 66.37434254, 107.62870114, 89.95113086, 78.9459868 ,\n 55.74164355, 82.3878577 , 103.00808091, 103.92471237,\n 54.66425635, 79.29420733, 69.96882481, 72.17070955,\n 54.36635876, 90.92566622, 58.22358622, 53.1620387 ,\n 80.39951312, 82.04658674, 67.2881847 , 65.67690213,\n 108.66137872, 89.3519222 , 68.34664527, 94.67503978,\n 94.97036282, 86.17659241, 86.84161366, 74.67551798,\n 66.7113065 , 71.45805551, 100.196514 , 93.67226563,\n 56.40934843, 118.21100209, 82.9799281 , 88.62491982,\n 87.03019073, 57.79816924, 74.28981915, 82.88973048,\n 91.8436542 , 96.00113316, 69.95094311, 68.13895371,\n 52.58979642, 98.57099807, 80.22167709, 94.40292506,\n 83.31105998, 59.9926828 , 77.74859503, 94.56173455,\n 56.63442708, 70.99578669, 61.27584441, 71.64922331,\n 79.88262193, 74.69845801, 75.82961051, 87.75033865,\n 108.55912336, 57.56875358, 89.19231781, 58.2379943 ,\n 96.58276029, 75.04521478, 86.66189835, 74.0184621 ,\n 84.1612496 , 78.80287021, 82.40061125, 71.61704823,\n 96.52547727, 83.92205443, 89.18972954, 77.78097677,\n 79.54274882, 80.90208256, 114.55056822, 84.75557082,\n 75.76282328, 91.98124081, 74.84037922, 82.71645645,\n 83.13525585, 95.57640112, 69.43862495, 76.3638732 ,\n 78.8258523 , 82.79968036, 79.53328299, 97.14114949,\n 83.06939074, 77.62484757, 82.36762999, 67.32343718,\n 79.53488316, 110.55065547, 73.45111082, 74.11521981,\n 53.55164117, 97.21629361, 70.65778072, 81.77179281,\n 93.09918786, 84.64189076, 73.01267275, 82.05924077,\n 104.27148836, 73.18202528, 82.20035143, 70.11261095,\n 76.3956408 , 80.59874089, 76.60682684, 92.96876414,\n 77.70067312, 62.19425744, 74.23546655, 86.09897646,\n 95.3922493 , 65.96070337, 78.14115335, 88.77127978,\n 66.50819906, 69.67195613, 77.17798553, 73.6445897 ,\n 76.45981325, 91.34264205, 86.27955532, 70.29966357,\n 104.36673101, 97.05018014, 60.04493436, 85.11496696,\n 65.81390189, 84.86482526, 52.97518977, 74.57566331,\n 78.75310135, 85.77492172, 71.35722871, 106.11068985,\n 124.97210481, 64.21057686, 66.52047736, 106.94144838,\n 117.34122374, 88.50176593, 88.91385192, 107.97612164,\n 93.15004781, 58.76140505, 52.03809202, 92.62254407,\n 80.86381554, 100.43323091, 93.42890753, 72.523524 ,\n 80.29641867, 75.20448137, 74.66556513, 94.98379828,\n 74.78647058, 76.98338228, 74.84876293, 82.95665001,\n 88.35626775, 94.32698817, 71.14073011, 112.07773057,\n 80.00015636, 68.07692698, 113.49304812, 108.92762648,\n 68.67420516, 98.73515549, 84.32042451, 91.72139165,\n 66.4137705 , 69.93003756, 63.89062414, 82.64679468,\n 68.66601776, 64.30864809, 80.24191016, 53.43056906,\n 81.69719392, 87.34441433, 91.38770101, 59.16322365,\n 83.19726315, 61.75218797, 67.48675016, 64.09508776,\n 72.08408273, 80.05154611, 90.39502598, 89.20492664,\n 79.43005379, 103.62785263, 31.38686493, 72.00221598,\n 84.90436196, 87.71163029, 60.24661018, 98.14319475,\n 104.27390629, 82.13872268, 72.46160603, 75.6806385 ,\n 78.20961222, 67.04506469, 67.50202444, 90.78465477,\n 69.78798088, 84.57134186, 56.87529573, 84.77391649,\n 89.53774771, 65.85042351, 78.30539835, 78.39971562,\n 54.17582106, 66.14233741, 95.30687232, 80.38434415,\n 89.20059439, 60.08421512, 55.049331 , 101.52734573,\n 62.43599109, 78.53915989, 72.19896564, 116.79354989,\n 76.80593363, 70.02409537, 38.49989574, 73.04644811,\n 98.85180903, 79.5240704 , 66.31040168, 92.4980046 ,\n 83.34256192, 66.99625849, 96.27910494, 95.358351 ,\n 79.84098206, 83.14032522, 42.40925601, 54.34194303,\n 84.06615973, 82.17376391, 70.67851012, 85.09767893,\n 80.32794527, 85.17526058, 97.30100338, 66.91553603,\n 76.07403987, 80.76033764, 95.91036179, 82.08802473,\n 98.55080876, 97.10028467, 101.13288782, 81.91445241,\n 66.74373645, 90.14807268, 90.10897824, 67.71922793,\n 72.12689907, 62.45830276, 69.12897818, 75.65268046,\n 84.49480148, 100.63329536, 87.37431219, 105.89171019,\n 75.28306231, 70.00937135, 89.03671396, 74.51401316,\n 73.79273308, 100.41392714, 68.69070397, 88.20822103,\n 76.00259474, 106.61250194, 82.88183663, 76.27135957,\n 74.95698129, 93.63350012, 88.9619559 , 62.85201103,\n 119.69006733, 85.86409883, 55.75743606, 75.00489182,\n 58.06456391, 52.26432328, 66.66447096, 75.07032703,\n 84.59732897, 112.54736571, 65.34570336, 102.17736386,\n 40.37932797, 83.04954136, 77.69724422, 105.90650084,\n 80.45674399, 71.68883905, 98.73184451, 76.13710261,\n 66.20507679, 88.74955062, 80.0510249 , 76.22040964,\n 93.95306912, 52.35187424, 70.61081767, 95.22725407,\n 108.94784107, 72.24788481, 88.79595569, 50.5979318 ,\n 62.04383021, 82.92286625, 73.21143122, 53.05418957,\n 87.40469357, 94.69362199, 78.83425313, 103.18034128,\n 91.77577212, 67.46671285, 68.03901009, 62.2977924 ,\n 97.5852646 , 79.90403623, 77.95140453, 55.37994377,\n 89.23457844, 90.37887043, 89.85164318, 73.76839666,\n 87.96911602, 68.63450746, 93.21846679, 53.30857204,\n 94.15702001, 90.69365635, 96.38657258, 81.77837411,\n 79.47635508, 67.02666039, 84.07348833, 110.67955405,\n 91.05912686, 85.44147472, 65.16901929, 84.73650976,\n 81.89662136, 55.35194992, 72.66891519, 87.76721338,\n 90.88372285, 57.96348731, 89.68013973, 62.74481238,\n 114.52531551, 92.67234425, 87.31186873, 78.60200183,\n 86.59058664, 66.94814514, 77.3853412 , 91.71363056,\n 95.70888858, 52.45127237, 88.63758894, 97.57111284,\n 102.01999059, 75.96281703, 88.36166644, 93.34628342,\n 73.53905254, 59.92934719, 66.59948145, 56.78496989,\n 105.70030441, 72.86444968, 52.39540333, 74.45779479,\n 45.66426504, 56.3253082 , 61.62810162, 83.84735818,\n 80.53413791, 74.71040154, 92.85498595, 94.88784482,\n 96.30760768, 57.32765239, 82.83004411, 79.46457279,\n 49.90957363, 60.65314868, 90.93552368, 106.21061945,\n 97.13211144, 71.44100454, 90.05329611, 91.53492172,\n 71.46036606, 68.34357157, 80.42264456, 52.26701607,\n 48.28971326, 50.09431862, 52.27223857, 53.59897973,\n 81.96496589, 59.92479546, 64.00557478, 113.15028134,\n 48.87116061, 81.9481499 , 95.142522 , 76.16819745,\n 99.58493419, 94.06452704, 83.05951515, 64.0776772 ,\n 98.85617806, 53.79063833, 67.38281794, 88.12377387,\n 89.03606168, 71.96180971, 94.82115345, 75.35454868,\n 85.71719855, 77.85575022, 55.38749871, 88.81850218,\n 98.28893289, 71.79790379, 86.74856436, 100.86891044,\n 106.94848343, 68.17002494, 95.00452271, 96.1588338 ,\n 87.02101749, 79.34469034, 93.11547607, 81.4201332 ,\n 79.61242788, 80.14276989, 66.31126804, 73.81342493,\n 84.47742817, 87.65835947, 65.64731682, 86.66836892,\n 80.54654032, 84.83075141, 72.89043985, 61.3376971 ,\n 84.94655925, 87.38518507, 76.41231247, 106.23342075,\n 59.71539452, 70.96316145, 86.07725176, 109.16186329,\n 77.98466482, 61.86883949, 93.33239525, 71.42031957,\n 55.60559768, 105.19788732, 76.43995609, 101.1628942 ,\n 58.91082047, 67.00069345, 76.45884388, 73.54853117,\n 69.62413178, 74.36808765, 91.04834957, 69.78617132,\n 75.60903984, 89.53931323, 83.58114772, 79.9388412 ,\n 55.10438037, 87.65131276, 49.84807055, 52.41289143,\n 73.60261926, 86.15417227, 84.3558208 , 100.35194259,\n 78.19168592, 73.3648356 , 86.51749328, 80.33272539,\n 80.30453794, 51.27924021, 76.11370381, 74.36769789,\n 79.69049874, 77.0311673 , 92.05156246, 70.55832463,\n 71.77061074, 102.05166634, 54.32326398, 65.78529409,\n 70.88825347, 75.95280562, 59.98473392, 78.69470919,\n 56.4382883 , 89.81907081, 39.71499043, 62.08117787,\n 73.71371881, 79.24108502, 60.78772328, 72.11092866,\n 85.52384131, 73.39225323, 81.39602368, 64.41522371,\n 76.49433703, 65.1950397 , 90.5638382 , 94.66606541,\n 77.59274208, 85.57891274, 87.78522439, 108.15796205,\n 84.58319919, 108.12112397, 72.02513902, 76.48664057,\n 68.59305846, 84.35962562, 70.61111213, 87.87455868,\n 52.1882934 , 81.87445995, 48.17687999, 53.51759063,\n 105.03063346, 65.52206369, 109.02272228, 84.14593548])" + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Generate random numbers\n", + "# np.random.normal(mu, sigma, size)\n", + "normal_array = np.random.normal(79, 15, 1000)\n", + "normal_array\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Numpy and Statistics" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "(array([ 1., 2., 0., 2., 4., 1., 1., 2., 3., 7., 6., 22., 18.,\n 20., 16., 17., 27., 19., 41., 36., 37., 41., 50., 57., 39., 49.,\n 47., 49., 50., 48., 50., 33., 32., 32., 24., 21., 14., 13., 14.,\n 12., 10., 10., 6., 6., 3., 3., 1., 2., 1., 1.]),\n array([ 31.38686493, 33.25856972, 35.13027452, 37.00197932,\n 38.87368412, 40.74538891, 42.61709371, 44.48879851,\n 46.36050331, 48.2322081 , 50.1039129 , 51.9756177 ,\n 53.8473225 , 55.71902729, 57.59073209, 59.46243689,\n 61.33414169, 63.20584649, 65.07755128, 66.94925608,\n 68.82096088, 70.69266568, 72.56437047, 74.43607527,\n 76.30778007, 78.17948487, 80.05118966, 81.92289446,\n 83.79459926, 85.66630406, 87.53800885, 89.40971365,\n 91.28141845, 93.15312325, 95.02482805, 96.89653284,\n 98.76823764, 100.63994244, 102.51164724, 104.38335203,\n 106.25505683, 108.12676163, 109.99846643, 111.87017122,\n 113.74187602, 115.61358082, 117.48528562, 119.35699041,\n 121.22869521, 123.10040001, 124.97210481]),\n )" + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXMAAAD7CAYAAACYLnSTAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAATk0lEQVR4nO3df2xV9f3H8dctt7chgnXWewchhGRTY0ImEKZwp+lVM0uhvcF0ZAGMkCAKRgv0jzHFxoZNbdlImi3bzP5wXWZMBBQCa7BxGUqEshGJ0pixZFFaRMnlUKRQC7e9vef7B3K/Qu9v7u05/dzn4y/uuefe8+7nnvvy+L6fc47Htm1bAIAJrczpAgAAN48wBwADEOYAYADCHAAMQJgDgAEIcwAwAGEOAAbwOrXhr7/+RvG4+6e4V1VNUX//oNNlOIoxYAwkxkBydgzKyjz63vduSfm8Y2Eej9sTIswlTZg6i4kxYAwkxkBy7xjQZgEAAxDmAGAAwhwADECYA4ABCHMAMABhDgAGIMwBwACOzTMHxkNlZYV8Pt+Y5cPDwxoYiDpQEVAchDmM5vP5tHXr1jHLW1paJBHmMAdtFgAwAGEOAAYgzAHAAIQ5ABiAMAcAAxDmAGAAwhwADECYA4ABCHMAMABhDgAGIMwBwACEOQAYgDAHAAMQ5gBgAMIcAAxAmAOAAQhzADAAYQ4ABiDMAcAAhDkAGCCrGzo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qx44d6unp0RdffFFS4/Df//5X77zzjt5//319+OGHKisr0+HDh0tqDKTU+38pfi8ikYhWr16tn/3sZ1qwYIErx4Aj82/t379flmVp6dKlGhgY0NDQkDwez3UXEzt37pzxFxO74447FAwGdfvtt0uSfvrTn6qrq0uTJk1KrGP6RdUOHTqkYDCoqqoqSVf/F/r1118vuX0h1cX0blxu+lh89tlnWrt2rZ544gmtWbNG0tixccMYcGT+rY6ODnV2dmrv3r3asGGDHnnkEbW2tqqiokLHjh2TdHWGg+kXE3v44Yd16NAhXbx4UaOjo/rwww9VW1urkydPqq+vT6Ojo+rs7DR6HO655x51d3draGhItm3rwIEDuv/++0tuX5gzZ07Sz33GjBklMxaDg4N68skntXHjxkSQS3LlGHBknsH27dvV3NyswcFBzZ49W6tWrXK6pKKaM2eO1q5dq5UrV2pkZEQPPPCAVqxYoR/84AdqbGxUNBpVKBRSbW2t06UWzYMPPqj//Oc/amhoUHl5uX70ox/p6aef1qOPPlpS+0JFRYXa2tqSfu6l8r14++23de7cOXV0dKijo0OS9Mgjj2jjxo2uGwMutAUABqDNAgAGIMwBwACEOQAYgDAHAAMQ5gBgAMIcAAxAmAOAAQhzADDA/wEB/i4pezYlewAAAABJRU5ErkJggg==\n", + "image/svg+xml": "\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n", + "text/plain": "
" + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import matplotlib.pyplot as plt\n", + "import seaborn as sns\n", + "sns.set()\n", + "plt.hist(normal_array, color=\"grey\", bins=50)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [], + "source": [ + "# numpy.asarray()\n", + "# Asarray\n", + "# The asarray()function is used when you want to convert an input to an array. \n", + "# The input could be a lists, tuple, ndarray, etc." + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [], + "source": [ + "four_by_four_matrix = np.matrix(np.ones((4,4), dtype=float))" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "matrix([[1., 1., 1., 1.],\n [1., 1., 1., 1.],\n [1., 1., 1., 1.],\n [1., 1., 1., 1.]])" + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "four_by_four_matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "matrix([[1., 1., 1., 1.],\n [1., 1., 1., 1.],\n [2., 2., 2., 2.],\n [1., 1., 1., 1.]])" + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.asarray(four_by_four_matrix)[2] = 2\n", + "four_by_four_matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [], + "source": [ + "# numpy.arange() in Python with Example\n", + "# Whay is Arrange?\n", + "# Sometimes, you want to create values that are evenly spaced within a defined interval. \n", + "# For instance, you want to create values from 1 to 10; you can use numpy.arange() function\n" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "range(0, 11, 2)" + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# creating list using range(starting, stop, step)\n", + "lst = range(0, 11, 2)\n", + "lst" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "0\n2\n4\n6\n8\n10\n" + } + ], + "source": [ + "for l in lst:\n", + " print(l)" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n 17, 18, 19])" + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Similar to range arange numpy.arange(start, stop, step)\n", + "whole_numbers = np.arange(0, 20, 1)\n", + "whole_numbers" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,\n 18, 19])" + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "natural_numbers = np.arange(1, 20, 1)\n", + "natural_numbers" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19])" + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "odd_numbers = np.arange(1, 20, 2)\n", + "odd_numbers" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([ 2, 4, 6, 8, 10, 12, 14, 16, 18])" + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "even_numbers = np.arange(2, 20, 2)\n", + "even_numbers" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([1. , 1.44444444, 1.88888889, 2.33333333, 2.77777778,\n 3.22222222, 3.66666667, 4.11111111, 4.55555556, 5. ])" + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# numpy.linspace()\n", + "# numpy.logspace() in Python with Example\n", + "# For instance, it can be used to create 10 values from 1 to 5 evenly spaced.\n", + "np.linspace(1.0, 5.0, num=10)" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([1. , 1.8, 2.6, 3.4, 4.2])" + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# not to include the last value in the interval\n", + "np.linspace(1.0, 5.0, num=5, endpoint=False)" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [], + "source": [ + "# LogSpace\n", + "# LogSpace returns even spaced numbers on a log scale. Logspace has the same parameters as np.linspace.\n", + "\n", + "# Syntax:\n", + "\n", + "# numpy.logspace(start, stop, num, endpoint)" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([ 100. , 464.15888336, 2154.43469003, 10000. ])" + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.logspace(2, 4.0, num=4)" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [], + "source": [ + "# to check the size of an array\n", + "x = np.array([1,2,3], dtype=np.complex128)" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([1.+0.j, 2.+0.j, 3.+0.j])" + }, + "execution_count": 68, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "16" + }, + "execution_count": 69, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x.itemsize" + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[1, 2, 3],\n [4, 5, 6]])" + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# indexing and Slicing NumPy Arrays in Python \n", + "\n", + "np_list = np.array([(1,2,3), (4,5,6)])\n", + "np_list\n" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "First row: [1 2 3]\nSecond row: [4 5 6]\n" + } + ], + "source": [ + "print('First row: ', np_list[0])\n", + "print('Second row: ', np_list[1])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "First column: [1 4]\nSecond column: [2 5]\nThird column: [3 6]\n" + } + ], + "source": [ + "print('First column: ', np_list[:,0])\n", + "print('Second column: ', np_list[:,1])\n", + "print('Third column: ', np_list[:,2])\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "## NumPy Statistical Functions with Example\n", + "NumPy has quite a few useful statistical functions for finding minimum, maximum, percentile standard deviation and variance, etc from the given elements in the array.\n", + "The functions are explained as follows βˆ’\n", + "Statistical function\n", + "Numpy is equipped with the robust statistical function as listed below\n", + "\n", + "- Numpy Functions\n", + " - Min\tnp.min()\n", + " - Max\tnp.max()\n", + " - Mean\tnp.mean()\n", + " - Median\tnp.median()\n", + " - Standard deviation\tnp.std()" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "min: 1\nmax: 55\nmean: 14.777777777777779\nsd: 18.913709183069525\n" + } + ], + "source": [ + "np_normal_dis = np.random.normal(5, 0.5, 100)\n", + "np_normal_dis\n", + "## min, max, mean, median, sd\n", + "print('min: ', two_dimension_array.min())\n", + "print('max: ', two_dimension_array.max())\n", + "print('mean: ',two_dimension_array.mean())\n", + "# print('median: ', two_dimension_array.median())\n", + "print('sd: ', two_dimension_array.std())" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "[[ 1 2 3]\n [ 4 55 44]\n [ 7 8 9]]\nColumn with minimum: [1 2 3]\nColumn with maximum: [ 7 55 44]\n=== Row ==\nRow with minimum: [1 4 7]\nRow with maximum: [ 3 55 9]\n" + } + ], + "source": [ + "print(two_dimension_array)\n", + "print('Column with minimum: ', np.amin(two_dimension_array,axis=0))\n", + "print('Column with maximum: ', np.amax(two_dimension_array,axis=0))\n", + "print('=== Row ==')\n", + "print('Row with minimum: ', np.amin(two_dimension_array,axis=1))\n", + "print('Row with maximum: ', np.amax(two_dimension_array,axis=1))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## How to create repeating sequences?\n" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "Tile: [1 2 3 1 2 3]\nRepeat: [1 1 2 2 3 3]\n" + } + ], + "source": [ + "a = [1,2,3] \n", + "\n", + "# Repeat whole of 'a' two times\n", + "print('Tile: ', np.tile(a, 2))\n", + "\n", + "# Repeat each element of 'a' two times\n", + "print('Repeat: ', np.repeat(a, 2))\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## How to generate random numbers?" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "0.9476490025120005\n" + } + ], + "source": [ + "# One random number between [0,1)\n", + "one_random_num = np.random.random()\n", + "one_random_in = np.random\n", + "print(one_random_num)" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "[[0.85805543 0.94673813 0.11857992]\n [0.39495196 0.99733241 0.90835007]]\n" + } + ], + "source": [ + "# Random numbers between [0,1) of shape 2,3\n", + "r = np.random.random(size=[2,3])\n", + "print(r)" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "['a' 'e' 'u' 'i' 'a' 'u' 'o' 'a' 'a' 'i']\n" + } + ], + "source": [ + "print(np.random.choice(['a', 'e', 'i', 'o', 'u'], size=10)) " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 79, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[0.20980067, 0.48290936],\n [0.57274305, 0.36054907]])" + }, + "execution_count": 79, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "## Random numbers between [0, 1] of shape 2, 2\n", + "rand = np.random.rand(2,2)\n", + "rand" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[-1.46836664, 0.61438705],\n [ 0.51575582, 0.89551303]])" + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rand2 = np.random.randn(2,2)\n", + "rand2\n" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[6, 2, 6],\n [3, 8, 7],\n [8, 3, 5],\n [2, 4, 3],\n [3, 7, 3]])" + }, + "execution_count": 81, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Random integers between [0, 10) of shape 2,5\n", + "rand_int = np.random.randint(0, 10, size=[5,3])\n", + "rand_int" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": "min: 3.181694913603133\nmax: 6.358778013894176\nmean: 4.98118971737671\nmedian: 4.993503158562607\nmode: ModeResult(mode=array([3.18169491]), count=array([1]))\nsd: 0.4917061541395749\n" + } + ], + "source": [ + "from scipy import stats\n", + "np_normal_dis = np.random.normal(5, 0.5, 1000)\n", + "np_normal_dis\n", + "## min, max, mean, median, sd\n", + "print('min: ', np.min(np_normal_dis))\n", + "print('max: ', np.max(np_normal_dis))\n", + "print('mean: ', np.mean(np_normal_dis))\n", + "print('median: ', np.median(np_normal_dis))\n", + "print('mode: ', stats.mode(np_normal_dis))\n", + "print('sd: ', np.std(np_normal_dis))" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "(array([ 3., 1., 2., 4., 6., 20., 31., 44., 87., 80., 114.,\n 112., 124., 87., 110., 76., 45., 29., 21., 2., 2.]),\n array([3.18169491, 3.33298459, 3.48427426, 3.63556393, 3.7868536 ,\n 3.93814327, 4.08943294, 4.24072261, 4.39201229, 4.54330196,\n 4.69459163, 4.8458813 , 4.99717097, 5.14846064, 5.29975031,\n 5.45103999, 5.60232966, 5.75361933, 5.904909 , 6.05619867,\n 6.20748834, 6.35877801]),\n )" + }, + "execution_count": 83, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAD7CAYAAACCEpQdAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy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DGmtrbW5OTkmMzMTLN69WrT1dUVz7h3dPDgwcjRMgUFBeaPf/yjMcaY8+fPm+eff95kZ2ebxYsXm2vXrsUz5l3dLf+7775rvvWtb5k5c+aYZcuWmevXr8cz5m1KS0vNnDlzTGZmptmzZ48xxphnn33W/Pe//zXG3DqSKS8vz2RmZpr169ebcDgcz7i36Sv/3r17TXZ2tpk9e7Z55ZVX4hn1jg4cOBB5bZaUlJhQKNTrtdvc3Gyee+45k5WVZX7yk58k3Gu3r/xOuocTuwGAhRj2AQALUf4AYCHKHwAsRPkDgIUofwCwEOUPABai/AHAQpQ/AFjo/wCRjqJv/b8/AQAAAABJRU5ErkJggg==\n", + "image/svg+xml": "\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n", + "text/plain": "
" + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "plt.hist(np_normal_dis, color=\"grey\", bins=21)" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": {}, + "outputs": [], + "source": [ + "# numpy.dot(): Dot Product in Python using Numpy\n", + "# Dot Product\n", + "# Numpy is powerful library for matrices computation. For instance, you can compute the dot product with np.dot\n", + "\n", + "# Syntax\n", + "\n", + "# numpy.dot(x, y, out=None)" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "14" + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "## Linear algebra\n", + "### Dot product: product of two arrays\n", + "f = np.array([1,2])\n", + "g = np.array([4,5])\n", + "### 1*4+2*5\n", + "np.dot(f, g)" + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "23" + }, + "execution_count": 86, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "## Linear algebra\n", + "### Dot product: product of two arrays\n", + "f = np.array([1,2,3])\n", + "g = np.array([4,5,3])\n", + "### 1*4+2*5 + 3*6\n", + "np.dot(f, g)" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [], + "source": [ + "# NumPy Matrix Multiplication with np.matmul() " + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[19, 22],\n [43, 50]])" + }, + "execution_count": 88, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "### Matmul: matruc product of two arrays\n", + "h = [[1,2],[3,4]] \n", + "i = [[5,6],[7,8]] \n", + "### 1*5+2*7 = 19\n", + "np.matmul(h, i)" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": {}, + "outputs": [], + "source": [ + "## Determinant 2*2 matrix\n", + "### 5*8-7*6np.linalg.det(i)" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "-1.999999999999999" + }, + "execution_count": 90, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.linalg.det(i)" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "metadata": {}, + "outputs": [], + "source": [ + "Z = np.zeros((8,8))\n", + "Z[1::2,::2] = 1\n", + "Z[::2,1::2] = 1" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([[0., 1., 0., 1., 0., 1., 0., 1.],\n [1., 0., 1., 0., 1., 0., 1., 0.],\n [0., 1., 0., 1., 0., 1., 0., 1.],\n [1., 0., 1., 0., 1., 0., 1., 0.],\n [0., 1., 0., 1., 0., 1., 0., 1.],\n [1., 0., 1., 0., 1., 0., 1., 0.],\n [0., 1., 0., 1., 0., 1., 0., 1.],\n [1., 0., 1., 0., 1., 0., 1., 0.]])" + }, + "execution_count": 92, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Z" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "metadata": {}, + "outputs": [], + "source": [ + "new_list = [ x + 2 for x in range(0, 11)]" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" + }, + "execution_count": 94, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "new_list" + ] + }, + { + "cell_type": "code", + "execution_count": 101, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])" + }, + "execution_count": 101, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np_arr = np.array(range(0, 11))\n", + "np_arr + 2" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "array([ 7, 9, 11, 13, 15])" + }, + "execution_count": 102, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x = np.array([1,2,3,4,5])\n", + "y = x * 2 + 5\n", + "y" + ] + }, + { + "cell_type": "code", + "execution_count": 105, + "metadata": {}, + "outputs": [ + { + "ename": "ValueError", + "evalue": "x and y must have same first dimension, but have shapes (1000,) and (5,)", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mxlabel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Temperature in oC'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mylabel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Pressure in atm'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtitle\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Temperature vs Pressure'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mxticks\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m6\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstep\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0.5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/opt/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py\u001b[0m in \u001b[0;36mplot\u001b[0;34m(scalex, scaley, data, *args, **kwargs)\u001b[0m\n\u001b[1;32m 2793\u001b[0m return gca().plot(\n\u001b[1;32m 2794\u001b[0m *args, scalex=scalex, scaley=scaley, **({\"data\": data} if data\n\u001b[0;32m-> 2795\u001b[0;31m is not None else {}), **kwargs)\n\u001b[0m\u001b[1;32m 2796\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2797\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_axes.py\u001b[0m in \u001b[0;36mplot\u001b[0;34m(self, scalex, scaley, data, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1664\u001b[0m \"\"\"\n\u001b[1;32m 1665\u001b[0m \u001b[0mkwargs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcbook\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnormalize_kwargs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmlines\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mLine2D\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_alias_map\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1666\u001b[0;31m \u001b[0mlines\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_lines\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1667\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mline\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mlines\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1668\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd_line\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 223\u001b[0m \u001b[0mthis\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 224\u001b[0m \u001b[0margs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 225\u001b[0;31m \u001b[0;32myield\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_plot_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mthis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 226\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 227\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mget_next_color\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py\u001b[0m in \u001b[0;36m_plot_args\u001b[0;34m(self, tup, kwargs)\u001b[0m\n\u001b[1;32m 389\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mindex_of\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtup\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 390\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 391\u001b[0;31m \u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_xy_from_xy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 392\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 393\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcommand\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'plot'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py\u001b[0m in \u001b[0;36m_xy_from_xy\u001b[0;34m(self, x, y)\u001b[0m\n\u001b[1;32m 268\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 269\u001b[0m raise ValueError(\"x and y must have same first dimension, but \"\n\u001b[0;32m--> 270\u001b[0;31m \"have shapes {} and {}\".format(x.shape, y.shape))\n\u001b[0m\u001b[1;32m 271\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m2\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 272\u001b[0m raise ValueError(\"x and y can be no greater than 2-D, but have \"\n", + "\u001b[0;31mValueError\u001b[0m: x and y must have same first dimension, but have shapes (1000,) and (5,)" + ] + } + ], + "source": [ + "plt.plot(x,y)\n", + "plt.xlabel('Temperature in oC')\n", + "plt.ylabel('Pressure in atm')\n", + "plt.title('Temperature vs Pressure')\n", + "plt.xticks(np.arange(0, 6, step=0.5))\n", + "plt.savefig('./numpy_files/linear_equation.png', dpi=None, facecolor='w', edgecolor='w',\n", + " orientation='portrait', papertype=None, format=None,\n", + " transparent=False, bbox_inches=None, pad_inches=0.1,\n", + " frameon=None, metadata=None)\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "[Text(0, 0.5, 'y'), Text(0.5, 0, 'x')]" + }, + "execution_count": 106, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEJCAYAAACKWmBmAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3de3RU5b34//fccplM7plJQhII13BLQIoFKUXbApFLRC1+S/EUe3rkaG0PLb8j/vipq6LWVetPjb2gq2J/x1WFc9BKoqka0WptbTgKKCTcCXeSMDOZ3CaZzGRuvz8i0QiZJJCdPTP5vNZimdn72Xs+7jUzn/08z36eRxMMBoMIIYQQfdCqHYAQQojwJolCC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SY6OvavPjii3R1dbFx40Z8Ph933XWXShGGh/4mxRTdjh8/zl133cV9991Hfn6+2uGEhVdffZXs7Gyuu+46duzYoXY4gIzMHrBXX32VP/zhDz0r7R05coTJkyezdetWTCaTytGpr6Ojgx//+MekpKTw5JNPEhMzspeTLCsrY8+ePTz22GMAbN68mWAw2LMei+h+AGLdunXcf//9LFu2TO1wwsa//uu/Yrfb0el0tLa24nK5uPnmm7n//vtVi0kSxRUqKCjg6NGjaocRNu655x7S09N5+OGH0WqlRdNqtfL973+fP//5z8THx7Nq1SoeffRRioqK1A4tLDQ0NHDLLbdQWlrKddddp3Y4YWvHjh188sknPP7446rGIU1P4qodOnSIv/71r0yYMIFbbrkF6G6T37Jli8qRqSczM5P169ezZs2ankkxJUl84Y9//CMej6fXD+CqVav4/ve/r2JUoi9SoxBCCBGStBEIIYQISRKFEEKIkCRRCCGECEkShRBCiJAkUQghhAhJEoUQQoiQJFEIIYQISRKFEAorKytj4cKFdHR04HK5WLJkCeXl5WqHJcSAyYA7IYbBf/7nf5KYmEhXVxc6nY5HH31U7ZCEGDBJFEIMg/b2dlasWEFcXBw7duwgNjZW7ZCEGDBpehJiGDgcDjweD21tbdhsNrXDEWJQpEYhhMK8Xi+rVq1i1apVBAIBXn31Vf77v/8bg8GgdmhCDIjUKIRQ2NNPP01GRga33XYb3/ve90hNTaW0tFTtsIQYMKlRCCGECElqFEIIIUKSRCGEECIkSRRCCCFCkkQhhBAiJEkUQgghQpJEIYQQIiRJFEIIIUKSRCGEECKk/x8BocHO09gdGQAAAABJRU5ErkJggg==\n", + "image/svg+xml": "\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n", + "text/plain": "
" + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "x = np.random.normal(size=1000)\n", + "ax = sns.distplot(x);\n", + "ax.set(xlabel=\"x\", ylabel='y')\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Summery\n", + "\n", + "To summarise, the main differences with python lists are:\n", + "\n", + "1. Arrays support vectorised operations, while lists don’t.\n", + "1. Once an array is created, you cannot change its size. You will have to create a new array or overwrite the existing one.\n", + "1. Every array has one and only one dtype. All items in it should be of that dtype.\n", + "1. An equivalent numpy array occupies much less space than a python list of lists.\n", + "1. numpy arrays support boolean indexing." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} \ No newline at end of file diff --git a/numpy.md b/numpy.md new file mode 100644 index 00000000..456b96e4 --- /dev/null +++ b/numpy.md @@ -0,0 +1,1675 @@ +###### Author: Asabeneh Yetayeh + +# Numpy(Numberic Python) + +In this note book you will cover all what you need to know about Numpy. Inditon to numpy we will see how to use matplot lib python library which will help us to draw graphs and visualize data. + +So far, we have been using vscode but from now on I would recommend using Jupter Notebook. To access jupter notebook let's install [anaconda](https://www.anaconda.com/) + + +```python +# Installation anconda numpy +``` + +## How to import numpy (Numeric Python) + + +```python +# A numpy array must have all items to be of the same data type, unlike lists. +# This is another significant difference. +``` + + +```python +# How to import numpy +import numpy as np + +``` + +## How to check package version in python + + +```python +# How to check the version of the numpy package +print('numpy:', np.__version__) + +``` + + numpy: 1.17.2 + + + +```python +# Checking the available methods +print(dir(np)) +``` + + ['ALLOW_THREADS', 'AxisError', 'BUFSIZE', 'CLIP', 'ComplexWarning', 'DataSource', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'False_', 'Inf', 'Infinity', 'MAXDIMS', 'MAY_SHARE_BOUNDS', 'MAY_SHARE_EXACT', 'MachAr', 'ModuleDeprecationWarning', 'NAN', 'NINF', 'NZERO', 'NaN', 'PINF', 'PZERO', 'RAISE', 'RankWarning', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID', 'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'ScalarType', 'Tester', 'TooHardError', 'True_', 'UFUNC_BUFSIZE_DEFAULT', 'UFUNC_PYVALS_NAME', 'VisibleDeprecationWarning', 'WRAP', '_NoValue', '_UFUNC_API', '__NUMPY_SETUP__', '__all__', '__builtins__', '__cached__', '__config__', '__doc__', '__file__', '__git_revision__', '__loader__', '__mkl_version__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_add_newdoc_ufunc', '_distributor_init', '_globals', '_mat', '_pytesttester', 'abs', 'absolute', 'absolute_import', 'add', 'add_docstring', 'add_newdoc', 'add_newdoc_ufunc', 'alen', 'all', 'allclose', 'alltrue', 'amax', 'amin', 'angle', 'any', 'append', 'apply_along_axis', 'apply_over_axes', 'arange', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh', 'argmax', 'argmin', 'argpartition', 'argsort', 'argwhere', 'around', 'array', 'array2string', 'array_equal', 'array_equiv', 'array_repr', 'array_split', 'array_str', 'asanyarray', 'asarray', 'asarray_chkfinite', 'ascontiguousarray', 'asfarray', 'asfortranarray', 'asmatrix', 'asscalar', 'atleast_1d', 'atleast_2d', 'atleast_3d', 'average', 'bartlett', 'base_repr', 'binary_repr', 'bincount', 'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'blackman', 'block', 'bmat', 'bool', 'bool8', 'bool_', 'broadcast', 'broadcast_arrays', 'broadcast_to', 'busday_count', 'busday_offset', 'busdaycalendar', 'byte', 'byte_bounds', 'bytes0', 'bytes_', 'c_', 'can_cast', 'cast', 'cbrt', 'cdouble', 'ceil', 'cfloat', 'char', 'character', 'chararray', 'choose', 'clip', 'clongdouble', 'clongfloat', 'column_stack', 'common_type', 'compare_chararrays', 'compat', 'complex', 'complex128', 'complex256', 'complex64', 'complex_', 'complexfloating', 'compress', 'concatenate', 'conj', 'conjugate', 'convolve', 'copy', 'copysign', 'copyto', 'core', 'corrcoef', 'correlate', 'cos', 'cosh', 'count_nonzero', 'cov', 'cross', 'csingle', 'ctypeslib', 'cumprod', 'cumproduct', 'cumsum', 'datetime64', 'datetime_as_string', 'datetime_data', 'deg2rad', 'degrees', 'delete', 'deprecate', 'deprecate_with_doc', 'diag', 'diag_indices', 'diag_indices_from', 'diagflat', 'diagonal', 'diff', 'digitize', 'disp', 'divide', 'division', 'divmod', 'dot', 'double', 'dsplit', 'dstack', 'dtype', 'dual', 'e', 'ediff1d', 'einsum', 'einsum_path', 'emath', 'empty', 'empty_like', 'equal', 'errstate', 'euler_gamma', 'exp', 'exp2', 'expand_dims', 'expm1', 'extract', 'eye', 'fabs', 'fastCopyAndTranspose', 'fft', 'fill_diagonal', 'find_common_type', 'finfo', 'fix', 'flatiter', 'flatnonzero', 'flexible', 'flip', 'fliplr', 'flipud', 'float', 'float128', 'float16', 'float32', 'float64', 'float_', 'float_power', 'floating', 'floor', 'floor_divide', 'fmax', 'fmin', 'fmod', 'format_float_positional', 'format_float_scientific', 'format_parser', 'frexp', 'frombuffer', 'fromfile', 'fromfunction', 'fromiter', 'frompyfunc', 'fromregex', 'fromstring', 'full', 'full_like', 'fv', 'gcd', 'generic', 'genfromtxt', 'geomspace', 'get_array_wrap', 'get_include', 'get_printoptions', 'getbufsize', 'geterr', 'geterrcall', 'geterrobj', 'gradient', 'greater', 'greater_equal', 'half', 'hamming', 'hanning', 'heaviside', 'histogram', 'histogram2d', 'histogram_bin_edges', 'histogramdd', 'hsplit', 'hstack', 'hypot', 'i0', 'identity', 'iinfo', 'imag', 'in1d', 'index_exp', 'indices', 'inexact', 'inf', 'info', 'infty', 'inner', 'insert', 'int', 'int0', 'int16', 'int32', 'int64', 'int8', 'int_', 'int_asbuffer', 'intc', 'integer', 'interp', 'intersect1d', 'intp', 'invert', 'ipmt', 'irr', 'is_busday', 'isclose', 'iscomplex', 'iscomplexobj', 'isfinite', 'isfortran', 'isin', 'isinf', 'isnan', 'isnat', 'isneginf', 'isposinf', 'isreal', 'isrealobj', 'isscalar', 'issctype', 'issubclass_', 'issubdtype', 'issubsctype', 'iterable', 'ix_', 'kaiser', 'kron', 'lcm', 'ldexp', 'left_shift', 'less', 'less_equal', 'lexsort', 'lib', 'linalg', 'linspace', 'little_endian', 'load', 'loads', 'loadtxt', 'log', 'log10', 'log1p', 'log2', 'logaddexp', 'logaddexp2', 'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'logspace', 'long', 'longcomplex', 'longdouble', 'longfloat', 'longlong', 'lookfor', 'ma', 'mafromtxt', 'mask_indices', 'mat', 'math', 'matmul', 'matrix', 'matrixlib', 'max', 'maximum', 'maximum_sctype', 'may_share_memory', 'mean', 'median', 'memmap', 'meshgrid', 'mgrid', 'min', 'min_scalar_type', 'minimum', 'mintypecode', 'mirr', 'mkl', 'mod', 'modf', 'moveaxis', 'msort', 'multiply', 'nan', 'nan_to_num', 'nanargmax', 'nanargmin', 'nancumprod', 'nancumsum', 'nanmax', 'nanmean', 'nanmedian', 'nanmin', 'nanpercentile', 'nanprod', 'nanquantile', 'nanstd', 'nansum', 'nanvar', 'nbytes', 'ndarray', 'ndenumerate', 'ndfromtxt', 'ndim', 'ndindex', 'nditer', 'negative', 'nested_iters', 'newaxis', 'nextafter', 'nonzero', 'not_equal', 'nper', 'npv', 'numarray', 'number', 'obj2sctype', 'object', 'object0', 'object_', 'ogrid', 'oldnumeric', 'ones', 'ones_like', 'os', 'outer', 'packbits', 'pad', 'partition', 'percentile', 'pi', 'piecewise', 'place', 'pmt', 'poly', 'poly1d', 'polyadd', 'polyder', 'polydiv', 'polyfit', 'polyint', 'polymul', 'polynomial', 'polysub', 'polyval', 'positive', 'power', 'ppmt', 'print_function', 'printoptions', 'prod', 'product', 'promote_types', 'ptp', 'put', 'put_along_axis', 'putmask', 'pv', 'quantile', 'r_', 'rad2deg', 'radians', 'random', 'rank', 'rate', 'ravel', 'ravel_multi_index', 'real', 'real_if_close', 'rec', 'recarray', 'recfromcsv', 'recfromtxt', 'reciprocal', 'record', 'remainder', 'repeat', 'require', 'reshape', 'resize', 'result_type', 'right_shift', 'rint', 'roll', 'rollaxis', 'roots', 'rot90', 'round', 'round_', 'row_stack', 's_', 'safe_eval', 'save', 'savetxt', 'savez', 'savez_compressed', 'sctype2char', 'sctypeDict', 'sctypeNA', 'sctypes', 'searchsorted', 'select', 'set_numeric_ops', 'set_printoptions', 'set_string_function', 'setbufsize', 'setdiff1d', 'seterr', 'seterrcall', 'seterrobj', 'setxor1d', 'shape', 'shares_memory', 'short', 'show_config', 'sign', 'signbit', 'signedinteger', 'sin', 'sinc', 'single', 'singlecomplex', 'sinh', 'size', 'sometrue', 'sort', 'sort_complex', 'source', 'spacing', 'split', 'sqrt', 'square', 'squeeze', 'stack', 'std', 'str', 'str0', 'str_', 'string_', 'subtract', 'sum', 'swapaxes', 'sys', 'take', 'take_along_axis', 'tan', 'tanh', 'tensordot', 'test', 'testing', 'tile', 'timedelta64', 'trace', 'tracemalloc_domain', 'transpose', 'trapz', 'tri', 'tril', 'tril_indices', 'tril_indices_from', 'trim_zeros', 'triu', 'triu_indices', 'triu_indices_from', 'true_divide', 'trunc', 'typeDict', 'typeNA', 'typecodes', 'typename', 'ubyte', 'ufunc', 'uint', 'uint0', 'uint16', 'uint32', 'uint64', 'uint8', 'uintc', 'uintp', 'ulonglong', 'unicode', 'unicode_', 'union1d', 'unique', 'unpackbits', 'unravel_index', 'unsignedinteger', 'unwrap', 'ushort', 'vander', 'var', 'vdot', 'vectorize', 'version', 'void', 'void0', 'vsplit', 'vstack', 'warnings', 'where', 'who', 'zeros', 'zeros_like'] + + + +```python +print(np.log10(2)) +print(np.not_equal(10, 10)) +``` + + 0.3010299956639812 + False + + +## Creating a list in python + + +```python +# Creating python List + +python_list = [1,2,3,4,5] +# Checking data types +print(type (python_list)) +print(python_list) +two_dimensional_list = [[0,1,2], [3,4,5], [6,7,8]] +print(two_dimensional_list) +``` + + + [1, 2, 3, 4, 5] + [[0, 1, 2], [3, 4, 5], [6, 7, 8]] + + +## Creating numpy array using numpy + + +```python +# Creating Numpy(Numerical Python) array from python list +numpy_array_from_list = np.array(python_list) +print(type (numpy_array_from_list)) +print(numpy_array_from_list) + +``` + + + [1 2 3 4 5] + + + +```python +numy_array_from_list2 = np.array(python_list) +numy_array_from_list2 +``` + + + + + array([1, 2, 3, 4, 5]) + + + + +```python +numy_array_from_list2 = np.array(python_list, dtype=float) +numy_array_from_list2 +``` + + + + + array([1., 2., 3., 4., 5.]) + + + + +```python +numpy_bool_array = np.array([0, 1, -1, 0, 0], dtype=bool) +numpy_bool_array +``` + + + + + array([False, True, True, False, False]) + + + + +```python + +numpy_two_dimensional_list = np.array(two_dimensional_list) +print(type (numpy_two_dimensional_list)) +print(numpy_two_dimensional_list) +``` + + + [[0 1 2] + [3 4 5] + [6 7 8]] + + + +```python +numpy_array_from_list +``` + + + + + array([1, 2, 3, 4, 5]) + + + + +```python +numpy_two_dimensional_list +``` + + + + + array([[0, 1, 2], + [3, 4, 5], + [6, 7, 8]]) + + + +### Converting numpy array to list + + +```python +# We can always convert an array back to a python list using tolist(). +np_to_list = numpy_array_from_list.tolist() +print(type (np_to_list)) +print('one dimensional array:', np_to_list) +print('two dimensional array: ', numpy_two_dimensional_list.tolist()) +``` + + + one dimensional array: [1, 2, 3, 4, 5] + two dimensional array: [[0, 1, 2], [3, 4, 5], [6, 7, 8]] + + + +```python +numpy_two_dimensional_list +``` + + + + + array([[0, 1, 2], + [3, 4, 5], + [6, 7, 8]]) + + + +## Creating numpy array from tuple + + +```python +# Numpy array from tuple + +# Creating tuple in Python + +python_tuple = (1,2,3,4,5) +print(type (python_tuple)) +print('python_tuple: ', python_tuple) + +numpy_array_from_tuple = np.array(python_tuple) +print(type (numpy_array_from_tuple)) +print('numpy_array_from_tuple: ', numpy_array_from_tuple) +``` + + + python_tuple: (1, 2, 3, 4, 5) + + numpy_array_from_tuple: [1 2 3 4 5] + + + +```python +numpy_array_from_tuple +``` + + + + + array([1, 2, 3, 4, 5]) + + + +## Shape of numpy array +The shape method provide the shape of the array as a tuple. The first is the row and the second is the column + + +```python +nums = np.array([1, 2, 3, 4, 5]) +print(nums) +print('shape of nums: ', nums.shape) +print(numpy_two_dimensional_list) +print('shape of numpy_two_dimensional_list: ', numpy_two_dimensional_list.shape) +three_by_four_array = np.array([[0, 1, 2, 3], + [4,5,6,7], + [8,9,10, 11]]) +print(three_by_four_array.shape) +``` + + [1 2 3 4 5] + shape of nums: (5,) + [[0 1 2] + [3 4 5] + [6 7 8]] + shape of numpy_two_dimensional_list: (3, 3) + (3, 4) + + +## Data type of numpy array + +Type of data types: str, int, float, complex, bool, list, None + + +```python +int_lists = [-3, -2, -1, 0, 1, 2,3] +int_array = np.array(int_lists) +float_array = np.array(int_lists, dtype=float) + +print(int_array) +print(int_array.dtype) +print(float_array) +print(float_array.dtype) + +``` + + [-3 -2 -1 0 1 2 3] + int64 + [-3. -2. -1. 0. 1. 2. 3.] + float64 + + +## Size of a numpy array +Instead of len size is used to get the length of items in a numpy array + + +```python +numpy_array_from_list.size +``` + + + + + 5 + + + + +```python +numpy_two_dimensional_list.size +``` + + + + + 9 + + + +### Mathematical Operation + + + + +```python +# Mathematical Operation + +# Addition +print('original array: ', numpy_array_from_list) +ten_plus_original = numpy_array_from_list + 10 +print(ten_plus_original) +ten_minus_original = numpy_array_from_list - 10 +print(ten_minus_original) +# Multiplication +ten_times_original = numpy_array_from_list * 10 +print(ten_times_original) +``` + + original array: [1 2 3 4 5] + [11 12 13 14 15] + [-9 -8 -7 -6 -5] + [10 20 30 40 50] + + + +```python +# Float numbers + +numpy_int_list = np.array([1,2,3,4]) +numpy_float_list = np.array([1.1, 2.0,3.2]) +numpy_float_list2 = np.array([1.1,2.0,3.2]) + +print(numpy_int_list.dtype) +print(numpy_float_list2.dtype) +print(numpy_float_list.dtype) +``` + + int64 + float64 + float64 + + +## Converting type from float to int + + +```python +# Converting type from float to int +numpy_float_list.astype('int') + +``` + + + + + array([1, 2, 3]) + + + + +```python +# Converting type from int to str +numpy_float_list.astype('int').astype('str') +``` + + + + + array(['1', '2', '3'], dtype=' + [[1 2 3] + [4 5 6] + [7 8 9]] + Shape: (3, 3) + Size: 9 + Data type: int64 + + + +```python +two_dimension_array +``` + + + + + array([[1, 2, 3], + [4, 5, 6], + [7, 8, 9]]) + + + +## How to extract specific items from an array? + + +```python +first_row = two_dimension_array[0] +second_row = two_dimension_array[1] +third_row = two_dimension_array[2] +print('First row:', first_row) +print('Second row:', second_row) +print('Third row: ', third_row) + +``` + + First row: [1 2 3] + Second row: [4 5 6] + Third row: [7 8 9] + + + +```python +first_column= two_dimension_array[:,0] +second_column = two_dimension_array[:,1] +third_column = two_dimension_array[:,2] +print('First column:', first_column) +print('Second column:', second_column) +print('Third column: ', third_column) +print(two_dimension_array) +``` + + First column: [1 4 7] + Second column: [2 5 8] + Third column: [3 6 9] + [[1 2 3] + [4 5 6] + [7 8 9]] + + +Slicing in numpy is similar to list + + +```python +first_two_rows_and_columns = two_dimension_array[0:2, 0:2] +first_two_rows_and_columns +``` + + + + + array([[1, 2], + [4, 5]]) + + + +## How to reverse the rows and the whole array? + + +```python +two_dimension_array[::] +``` + + + + + array([[1, 2, 3], + [4, 5, 6], + [7, 8, 9]]) + + + +### Reverse only the row positions + + +```python +two_dimension_array[::-1,] +``` + + + + + array([[7, 8, 9], + [4, 5, 6], + [1, 2, 3]]) + + + +### Reverse the row and column positions + + +```python +two_dimension_array[::-1,::-1] +``` + + + + + array([[9, 8, 7], + [6, 5, 4], + [3, 2, 1]]) + + + +## How to represent missing values and infinite? + + +```python +print(two_dimension_array) +two_dimension_array[1,1] = 55 +two_dimension_array[1,2] =44 +print(two_dimension_array) +``` + + [[1 2 3] + [4 5 6] + [7 8 9]] + [[ 1 2 3] + [ 4 55 44] + [ 7 8 9]] + + + +```python +# Numpy Zeroes +# numpy.zeros(shape, dtype=float, order='C') +numpy_zeroes = np.zeros((3,3),dtype=int,order='C') +numpy_zeroes +``` + + + + + array([[0, 0, 0], + [0, 0, 0], + [0, 0, 0]]) + + + + +```python +# Numpy Zeroes +numpy_ones = np.ones((3,3),dtype=int,order='C') +print(numpy_ones) +``` + + [[1 1 1] + [1 1 1] + [1 1 1]] + + + +```python +twoes = numpy_ones * 2 +``` + + +```python +# Reshape +# numpy.reshape(), numpy.flatten() +first_shape = np.array([(1,2,3), (4,5,6)]) +print(first_shape) +reshaped = first_shape.reshape(3,2) +print(reshaped) + +``` + + [[1 2 3] + [4 5 6]] + [[1 2] + [3 4] + [5 6]] + + + +```python +flattened = reshaped.flatten() +flattened +``` + + + + + array([1, 2, 3, 4, 5, 6]) + + + + +```python +## Horitzontal Stack +np_list_one = np.array([1,2,3]) +np_list_two = np.array([4,5,6]) + +print(np_list_one + np_list_two) + +print('Horizontal Append:', np.hstack((np_list_one, np_list_two))) +``` + + [5 7 9] + Horizontal Append: [1 2 3 4 5 6] + + + +```python +## Vertical Stack +print('Vertical Append:', np.vstack((np_list_one, np_list_two))) +``` + + Vertical Append: [[1 2 3] + [4 5 6]] + + +#### Generating Random Numbers + + +```python +# Generate a random float number +random_float = np.random.random() +random_float +``` + + + + + 0.6661632875670657 + + + + +```python +# Generate a random float number +random_floats = np.random.random(5) +random_floats +``` + + + + + array([0.12945387, 0.1859908 , 0.47805876, 0.51996342, 0.52458233]) + + + + +```python +# Generating a random integers between 0 and 10 +random_int = np.random.randint(0, 11) +random_int +``` + + + + + 7 + + + + +```python +# Generating a random integers between 2 and 11, and creating a one row array +random_int = np.random.randint(2,10, size=4) +random_int +``` + + + + + array([5, 8, 8, 9]) + + + + +```python +# Generating a random integers between 0 and 10 +random_int = np.random.randint(2,10, size=(3,3)) +random_int +``` + + + + + array([[8, 9, 5], + [9, 8, 3], + [2, 3, 8]]) + + + + +```python +# Generate random numbers +# np.random.normal(mu, sigma, size) +normal_array = np.random.normal(79, 15, 1000) +normal_array + + +``` + + + + + array([ 76.67233671, 87.8686846 , 64.80771996, 79.44136527, + 68.83066184, 102.85967631, 74.40838573, 58.56053793, + 93.76814784, 82.16082568, 86.80548555, 77.95291907, + 97.71514434, 95.94083876, 82.53018033, 73.74619803, + 67.07970869, 102.20984782, 81.67766599, 73.82096132, + 90.17632538, 102.87342877, 84.19855251, 81.11888938, + 63.42782472, 75.3734846 , 79.04423914, 56.52607352, + 58.30505483, 54.69555571, 63.25792739, 88.75239018, + 85.44533248, 59.76883843, 39.72683784, 78.1029094 , + 54.19952262, 82.383277 , 87.01010766, 73.09642208, + 81.99276776, 82.58990091, 72.71303439, 101.73499367, + 73.65596295, 81.89611334, 96.14703307, 74.9629613 , + 84.79491744, 90.77830881, 70.69085365, 69.27799996, + 74.07836137, 56.79410721, 76.08072393, 83.28246182, + 83.66382654, 80.79644627, 83.39674788, 73.68044176, + 59.74405724, 47.50763054, 50.99870066, 85.53776901, + 80.61131428, 62.66726385, 69.8289171 , 58.2394869 , + 86.5158869 , 86.92976422, 65.12965299, 101.9918336 , + 73.3855881 , 99.29788439, 82.48238578, 83.14592314, + 109.13987986, 87.18461073, 73.18647475, 76.04712709, + 67.2936962 , 56.39363409, 81.35106332, 84.5083442 , + 64.45556043, 91.48890982, 82.97061603, 88.02694597, + 79.98966974, 87.1672428 , 98.96048765, 79.90801913, + 66.33509656, 84.04023607, 88.09079879, 77.35006201, + 103.55727658, 64.13437043, 68.05358071, 90.89443625, + 82.79038989, 62.89514185, 74.97098809, 66.19397795, + 92.70537742, 71.0629109 , 96.37710058, 111.0582448 , + 82.49413524, 86.81684626, 51.59797622, 82.4090514 , + 67.44794517, 81.27167783, 56.5523663 , 70.31869978, + 73.27622806, 70.45432913, 69.65909073, 65.26697689, + 92.09133852, 77.6409777 , 75.12755482, 86.92392364, + 52.345763 , 61.21302273, 76.91865347, 101.50717646, + 65.45696696, 79.72489732, 76.1272494 , 95.31233116, + 115.96549733, 75.92209483, 79.08231261, 97.77244182, + 74.18461463, 66.86589353, 70.58006434, 37.59185572, + 103.64455596, 48.23404954, 47.68141346, 69.76670989, + 105.52887085, 67.35640534, 59.53778107, 79.01221476, + 63.25760905, 53.41243319, 67.56688095, 89.44295326, + 73.0249909 , 110.62094367, 75.30776079, 83.06746009, + 72.00044242, 95.55925297, 87.41229729, 75.83119383, + 81.76799949, 66.66909113, 111.87301683, 55.64386831, + 88.2057447 , 86.98310199, 90.64320901, 51.16660292, + 86.44260395, 101.81543578, 54.33572759, 86.59505355, + 74.96338672, 88.58073882, 99.97520135, 115.62885994, + 48.33081456, 87.46330109, 92.57228694, 105.5973409 , + 74.69521182, 85.18418419, 71.00401484, 94.4873179 , + 89.58091544, 78.19894226, 78.62597505, 97.70529476, + 48.9448779 , 54.77461514, 80.84647783, 56.72044906, + 53.17830126, 69.47376476, 62.70835212, 73.50984826, + 79.95708327, 60.30922811, 68.71736216, 92.40372794, + 86.23245168, 71.58967187, 58.57427101, 91.13298606, + 54.02876851, 91.61300175, 73.85802225, 74.1262673 , + 113.37398924, 83.62799161, 69.67276347, 90.92422022, + 93.80366456, 75.49340444, 69.68268106, 65.21188249, + 73.08843699, 76.9702737 , 86.63909332, 63.38692368, + 59.0107169 , 64.58012401, 67.77071814, 82.81680919, + 47.00115734, 77.89249231, 94.57639045, 82.62969276, + 89.2754606 , 75.03679732, 105.40459045, 82.31470981, + 91.73027956, 82.57265691, 73.93925755, 79.39961404, + 78.42971467, 81.85491373, 98.50921957, 89.41696616, + 64.5228743 , 86.34810062, 85.53403969, 65.44710598, + 97.61823581, 73.36500749, 78.7969976 , 82.64530182, + 102.5212311 , 60.24103391, 88.97487767, 67.74463234, + 87.06975383, 90.35731726, 113.93417792, 94.43622715, + 75.68177623, 79.23496178, 63.19462299, 67.36853029, + 39.35791739, 74.51434441, 72.60509108, 80.38587487, + 68.68165911, 67.91476795, 73.7642702 , 97.97756047, + 99.15996313, 89.43595584, 53.27369357, 75.35961475, + 93.21230424, 75.6875106 , 75.20803627, 86.68011244, + 73.46234329, 46.2650612 , 85.99510379, 89.78716287, + 86.54377973, 89.4421289 , 66.35904948, 73.69434082, + 72.16037244, 100.7404422 , 76.81167206, 92.47498529, + 51.99811087, 68.1875055 , 97.21350945, 73.98272047, + 79.9433559 , 91.32704877, 70.36341543, 91.53287551, + 64.0916329 , 82.05669765, 59.91901105, 67.06455073, + 90.82458082, 69.24155283, 86.00691215, 97.78612486, + 57.53429118, 55.13961827, 65.92071751, 69.12679024, + 80.24386507, 70.76561644, 52.38657486, 74.03314561, + 55.08560907, 78.93565259, 72.12457096, 88.1878194 , + 69.26543786, 94.26645154, 57.22213699, 85.08262645, + 75.15236761, 112.25159803, 60.69175095, 107.55714907, + 97.40508175, 100.34600206, 71.64266763, 69.56735445, + 105.37943464, 106.66581679, 69.88994757, 55.50599503, + 96.85984215, 82.27633384, 71.99542571, 87.3033245 , + 53.9629657 , 86.75436111, 93.71079875, 78.1735369 , + 59.12435725, 106.91289813, 90.55510253, 80.63892904, + 49.52196748, 69.92138936, 82.59370828, 64.36717287, + 83.46872542, 80.66546831, 73.272708 , 85.55761189, + 70.29998731, 85.27149783, 61.22698174, 112.1539227 , + 85.06829561, 105.62724187, 83.21087039, 91.47630885, + 52.61117972, 96.39363125, 98.7615724 , 82.3406285 , + 78.21209665, 81.68186011, 65.53179422, 81.636421 , + 48.28426725, 84.22834582, 72.65396863, 89.78723124, + 62.69033062, 67.42236676, 61.70774152, 91.00289665, + 65.8869877 , 98.85053178, 90.95893416, 80.71673232, + 69.1443606 , 83.24469518, 53.61281569, 98.41838607, + 95.89214815, 76.08288325, 105.95876474, 87.8123779 , + 98.83277115, 75.70467395, 64.52606003, 46.55761117, + 61.35279897, 79.03475418, 70.26356208, 83.15010813, + 71.35489747, 85.12422364, 79.6318843 , 64.65930113, + 50.39553485, 59.74637731, 97.17317934, 101.28981635, + 55.51070593, 65.5724488 , 56.9783323 , 76.69243571, + 80.22507493, 93.93824876, 74.27245434, 62.22895849, + 61.71693803, 91.50874511, 102.93624517, 66.51614867, + 73.66758854, 101.95706886, 80.17324289, 89.77788816, + 79.41557833, 83.12691023, 78.39868201, 82.1245395 , + 75.39745528, 64.15220095, 66.19591545, 78.52233881, + 69.45532022, 80.07279819, 92.05981037, 57.88406497, + 78.39408713, 103.98322005, 71.85190829, 85.69820843, + 78.01623836, 42.12347928, 82.10875153, 59.7121601 , + 75.6374047 , 68.03654408, 75.31781043, 57.31129216, + 82.6326405 , 83.43080808, 81.52065719, 61.07178023, + 65.89585315, 98.07305443, 57.04010365, 99.11343007, + 82.03829385, 94.96220101, 63.10779942, 43.75533224, + 60.96190311, 60.38889234, 86.01180327, 72.03287838, + 88.56135551, 83.20459124, 85.33961473, 65.09373303, + 72.95666996, 70.31639299, 82.84800507, 65.21994284, + 83.71082556, 59.30552118, 57.24161946, 91.59640687, + 81.07946716, 81.72062826, 104.82245391, 102.22642442, + 85.5935274 , 80.65595414, 85.21561212, 89.32052529, + 70.80532767, 81.2402353 , 73.3429679 , 83.96484983, + 102.14285344, 66.28045024, 69.08414849, 83.96027461, + 99.882723 , 92.56429669, 71.38334333, 91.29460474, + 74.73563361, 82.61344943, 101.38451941, 96.22447959, + 92.46992093, 73.64548057, 95.67625789, 97.30840065, + 86.18687145, 39.79818989, 67.44627234, 78.81800827, + 99.88127457, 97.08040669, 80.20672721, 61.6621477 , + 89.45069827, 69.2126993 , 105.30121908, 92.73651782, + 104.02718862, 82.63560985, 117.14218447, 70.78186465, + 69.38217047, 68.6752697 , 118.88261052, 94.16663109, + 58.85480966, 84.43706331, 93.91832945, 59.99542403, + 69.73006365, 87.14948387, 86.17056873, 72.04322939, + 74.60316737, 65.4121187 , 75.88172757, 73.0725911 , + 68.47916028, 88.94688011, 79.68974545, 66.22710966, + 75.65901653, 65.17336078, 82.7854841 , 68.54114688, + 63.5422467 , 85.27593096, 77.11949083, 85.1792345 , + 85.91031198, 94.40889745, 81.53460066, 78.13741406, + 48.50311626, 74.00832439, 62.64749899, 26.42484343, + 90.37956952, 47.85275007, 90.21932564, 71.54854049, + 66.33008326, 61.45646105, 83.24146521, 77.85092006, + 79.41867441, 82.35535991, 95.10042516, 104.55030347, + 68.41918381, 62.24245143, 52.68448442, 61.93464607, + 86.38263287, 81.40589031, 106.80202022, 76.64983598, + 67.98843927, 81.30232608, 90.07378784, 66.33965558, + 59.26391705, 90.22932022, 78.57688898, 60.99512356, + 53.16782133, 76.80554089, 73.18463521, 75.74775613, + 72.42763706, 84.15981253, 79.86702314, 107.59287088, + 42.72244939, 94.10074796, 65.11731346, 92.44057941, + 88.45199421, 49.7210141 , 70.92988608, 84.87914436, + 111.27471207, 71.10212581, 85.88122011, 85.39018312, + 64.75059945, 80.19182056, 52.28697701, 63.63607001, + 70.81836933, 92.12627834, 117.01393871, 84.55599041, + 74.38388382, 72.05047965, 80.96294247, 76.95375672, + 53.52743329, 68.26820071, 84.62245233, 83.76592911, + 71.66491816, 62.84764731, 101.77473998, 83.7109928 , + 88.14356241, 70.56990958, 63.4114506 , 97.03530829, + 75.29544449, 86.46570106, 90.71226994, 59.58744577, + 66.28889053, 81.81896037, 106.19049949, 76.79027375, + 103.79328945, 68.83879663, 86.96337876, 109.07240618, + 89.57507226, 71.02647491, 66.01655389, 63.71481491, + 84.96881056, 81.47094049, 41.08479295, 102.81032149, + 57.10553083, 74.69771968, 85.08750235, 77.86982387, + 66.24827223, 77.61800937, 87.85279737, 97.44114529, + 73.62465256, 84.87370213, 59.82819789, 83.51332999, + 76.1564969 , 92.80216207, 84.45078494, 98.12615727, + 92.82159165, 77.68306951, 56.70024893, 96.13691428, + 58.6947481 , 62.43855793, 89.44203656, 88.39339383, + 64.83174886, 80.20517572, 62.43358506, 90.35687599, + 56.89696185, 101.4910522 , 63.87426467, 64.76978812, + 86.19666835, 64.7236682 , 94.34248975, 75.09728512, + 91.30899086, 96.6812488 , 91.14172719, 82.51490688, + 89.22153835, 82.87563357, 84.59497932, 41.99164693, + 98.11955977, 79.61268968, 72.40763417, 73.97813269, + 58.1632078 , 62.83530224, 82.15621201, 71.28072756, + 114.50107295, 98.83008872, 64.0437643 , 99.65822453, + 75.48720903, 63.32837291, 76.20823217, 86.84282223, + 62.43082268, 73.15705444, 101.1511228 , 76.82948915, + 81.40991749, 69.48832828, 93.78545288, 84.11019295, + 74.84590881, 80.41138779, 119.75165158, 94.30283763, + 62.60960855, 80.05025988, 104.81265311, 83.38125656, + 38.78328615, 62.41916009, 70.16735618, 51.44288365, + 92.80525403, 84.92470846, 66.26844763, 74.71143692, + 63.24518316, 101.03067104, 87.61812768, 81.78062237, + 79.26854548, 82.45239206, 62.84682868, 75.85374972, + 81.50671709, 91.61193178, 84.80540264, 76.83093669, + 85.07574758, 78.12229555, 66.29072864, 95.26350438, + 56.05352073, 75.24843365, 94.25579772, 80.29484646, + 54.79358077, 80.00636677, 98.09007754, 65.05236219, + 92.21169732, 93.78045193, 100.08258446, 50.34210852, + 78.48684671, 92.46745685, 84.84801383, 80.80624528, + 105.39277867, 95.79633397, 84.89636306, 113.4129892 , + 94.37919945, 33.04894125, 57.62445042, 74.70068129, + 84.36545129, 58.65159412, 59.80499077, 72.37282525, + 63.67362837, 60.15747326, 92.27103467, 67.58559178, + 71.78018188, 78.50521982, 57.14143778, 87.75269721, + 70.3938368 , 85.84713936, 75.96861357, 77.60591163, + 73.37361875, 94.88377692, 66.33736786, 67.73206898, + 98.54323406, 97.7942897 , 32.15593272, 92.2224777 , + 86.09657291, 79.07206812, 59.96670651, 67.31216781, + 53.64584436, 55.49172965, 87.88340258, 93.21390739, + 74.83629979, 74.97550995, 104.20264824, 85.90602294, + 98.25959023, 82.32831776, 91.19296573, 68.66385157, + 72.47319467, 66.32588349, 69.46771085, 84.80546774, + 92.2537018 , 91.61146021, 87.97125321, 77.40162354, + 56.81359943, 100.63347184, 46.06026334, 64.3072636 , + 73.16833499, 66.58449357, 77.1759305 , 80.95588782, + 98.53819261, 93.8004291 , 71.79955175, 71.8092341 , + 67.48364477, 76.92938082, 80.90556577, 76.3361884 , + 56.08189834, 69.72013329, 83.23890509, 87.63876162, + 91.6671542 , 65.9815465 , 72.61972745, 98.36138944, + 79.27809954, 83.22987584, 87.65365004, 89.72387738, + 77.28925164, 96.80686114, 66.27593891, 58.22356418, + 69.00110634, 98.69032179, 83.51534823, 54.84798906, + 65.53428591, 64.14493646, 73.09656991, 80.90855247, + 68.49764325, 66.70828679, 88.94583478, 68.08884137, + 114.20054981, 48.43412772, 65.62243783, 76.5361132 , + 92.80262402, 73.745952 , 77.88874597, 103.32373442, + 82.78186246, 87.31269531, 82.7184332 , 93.00860143, + 86.81186734, 81.88725671, 85.57497866, 83.06657941, + 73.92135462, 64.67840907, 54.1324434 , 44.56198425, + 103.74716492, 73.00720986, 79.70037455, 117.226086 , + 90.95959027, 82.93746876, 68.01202978, 51.38653362, + 49.21376817, 82.98155396, 63.73945045, 71.87810968, + 67.47155016, 50.17812178, 68.00005018, 74.54213222, + 86.46204427, 81.88129502, 102.2539116 , 109.56599738, + 101.67600164, 59.82763125, 66.7090957 , 48.75955951, + 84.40734607, 86.4125707 , 31.21236081, 76.260938 , + 94.59278233, 112.3969095 , 82.55898885, 66.22114921, + 80.83856717, 85.08680709, 68.69636286, 69.71161312, + 76.3196622 , 78.68149223, 88.42004846, 78.94426232, + 54.8348913 , 82.21921133, 71.59374818, 82.0954091 , + 62.69406376, 79.16889409, 67.81528319, 95.83872873, + 74.96783523, 81.70211669, 97.29360667, 51.07465606, + 70.03123751, 94.59751783, 68.4839708 , 51.8779431 , + 43.06271614, 53.56724106, 38.99403909, 92.53214605, + 100.08867662, 74.91608135, 76.43190909, 77.23653514, + 101.68713224, 74.48287587, 80.29475109, 86.49937422, + 74.18560655, 90.32342146, 67.54203627, 61.65836826, + 65.90214024, 90.18667155, 84.24811988, 87.31264766, + 65.51077902, 73.6819876 , 85.97917178, 84.60220551, + 83.61993451, 81.97165845, 77.12380967, 85.92629768, + 68.07735309, 97.04263534, 107.17028674, 56.66687639, + 63.0328498 , 95.71169257, 66.41415792, 73.01941362, + 77.43739944, 80.91838286, 76.94361736, 92.45966561, + 64.28909701, 90.86504202, 64.31354427, 68.00874105, + 74.90902052, 46.84873109, 96.71448387, 92.88217861, + 58.61271069, 74.34878286, 76.81571832, 100.83234903, + 87.04080477, 76.17316306, 76.60724189, 57.03191229, + 102.49683378, 84.94708014, 97.89869778, 51.74458192, + 71.56589366, 71.92667719, 66.78215404, 90.44885288]) + + + + +```python + +``` + +## Numpy and Statistics + + +```python +import matplotlib.pyplot as plt +import seaborn as sns +sns.set() +plt.hist(normal_array, color="grey", bins=50) +``` + + + + + (array([ 1., 0., 1., 2., 0., 1., 3., 3., 4., 2., 4., 10., 7., + 12., 15., 13., 20., 26., 16., 32., 36., 42., 38., 37., 35., 54., + 50., 40., 40., 55., 56., 49., 45., 29., 37., 26., 26., 23., 28., + 12., 22., 10., 11., 5., 3., 6., 4., 4., 3., 2.]), + array([ 26.42484343, 28.2913796 , 30.15791576, 32.02445192, + 33.89098809, 35.75752425, 37.62406041, 39.49059657, + 41.35713274, 43.2236689 , 45.09020506, 46.95674123, + 48.82327739, 50.68981355, 52.55634972, 54.42288588, + 56.28942204, 58.1559582 , 60.02249437, 61.88903053, + 63.75556669, 65.62210286, 67.48863902, 69.35517518, + 71.22171134, 73.08824751, 74.95478367, 76.82131983, + 78.687856 , 80.55439216, 82.42092832, 84.28746449, + 86.15400065, 88.02053681, 89.88707297, 91.75360914, + 93.6201453 , 95.48668146, 97.35321763, 99.21975379, + 101.08628995, 102.95282611, 104.81936228, 106.68589844, + 108.5524346 , 110.41897077, 112.28550693, 114.15204309, + 116.01857926, 117.88511542, 119.75165158]), + ) + + + + +```python + +``` + + +```python +# numpy.asarray() +# Asarray +# The asarray()function is used when you want to convert an input to an array. +# The input could be a lists, tuple, ndarray, etc. +``` + + +```python +four_by_four_matrix = np.matrix(np.ones((4,4), dtype=float)) +``` + + +```python +four_by_four_matrix +``` + + + + + matrix([[1., 1., 1., 1.], + [1., 1., 1., 1.], + [1., 1., 1., 1.], + [1., 1., 1., 1.]]) + + + + +```python +np.asarray(four_by_four_matrix)[2] = 2 +four_by_four_matrix +``` + + + + + matrix([[1., 1., 1., 1.], + [1., 1., 1., 1.], + [2., 2., 2., 2.], + [1., 1., 1., 1.]]) + + + + +```python +# numpy.arange() in Python with Example +# Whay is Arrange? +# Sometimes, you want to create values that are evenly spaced within a defined interval. +# For instance, you want to create values from 1 to 10; you can use numpy.arange() function + +``` + + +```python +# creating list using range(starting, stop, step) +lst = range(0, 11, 2) +lst +``` + + + + + range(0, 11, 2) + + + + +```python +for l in lst: + print(l) +``` + + 0 + 2 + 4 + 6 + 8 + 10 + + + +```python +# Similar to range arange numpy.arange(start, stop, step) +whole_numbers = np.arange(0, 20, 1) +whole_numbers +``` + + + + + array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19]) + + + + +```python +natural_numbers = np.arange(1, 20, 1) +natural_numbers +``` + + + + + array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19]) + + + + +```python +odd_numbers = np.arange(1, 20, 2) +odd_numbers +``` + + + + + array([ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) + + + + +```python +even_numbers = np.arange(2, 20, 2) +even_numbers +``` + + + + + array([ 2, 4, 6, 8, 10, 12, 14, 16, 18]) + + + + +```python +# numpy.linspace() +# numpy.logspace() in Python with Example +# For instance, it can be used to create 10 values from 1 to 5 evenly spaced. +np.linspace(1.0, 5.0, num=10) +``` + + + + + array([1. , 1.44444444, 1.88888889, 2.33333333, 2.77777778, + 3.22222222, 3.66666667, 4.11111111, 4.55555556, 5. ]) + + + + +```python +# not to include the last value in the interval +np.linspace(1.0, 5.0, num=5, endpoint=False) +``` + + + + + array([1. , 1.8, 2.6, 3.4, 4.2]) + + + + +```python +# LogSpace +# LogSpace returns even spaced numbers on a log scale. Logspace has the same parameters as np.linspace. + +# Syntax: + +# numpy.logspace(start, stop, num, endpoint) +``` + + +```python +np.logspace(2, 4.0, num=4) +``` + + + + + array([ 100. , 464.15888336, 2154.43469003, 10000. ]) + + + + +```python +# to check the size of an array +x = np.array([1,2,3], dtype=np.complex128) +``` + + +```python +x +``` + + + + + array([1.+0.j, 2.+0.j, 3.+0.j]) + + + + +```python +x.itemsize +``` + + + + + 16 + + + + +```python +# indexing and Slicing NumPy Arrays in Python + +np_list = np.array([(1,2,3), (4,5,6)]) +np_list + +``` + + + + + array([[1, 2, 3], + [4, 5, 6]]) + + + + +```python +print('First row: ', np_list[0]) +print('Second row: ', np_list[1]) + +``` + + First row: [1 2 3] + Second row: [4 5 6] + + + +```python +print('First column: ', np_list[:,0]) +print('Second column: ', np_list[:,1]) +print('Third column: ', np_list[:,2]) + +``` + + First column: [1 4] + Second column: [2 5] + Third column: [3 6] + + + +## NumPy Statistical Functions with Example +NumPy has quite a few useful statistical functions for finding minimum, maximum, percentile standard deviation and variance, etc from the given elements in the array. +The functions are explained as follows βˆ’ +Statistical function +Numpy is equipped with the robust statistical function as listed below + +- Numpy Functions + - Min np.min() + - Max np.max() + - Mean np.mean() + - Median np.median() + - Standard deviation np.std() + + +```python +np_normal_dis = np.random.normal(5, 0.5, 100) +np_normal_dis +## min, max, mean, median, sd +print('min: ', two_dimension_array.min()) +print('max: ', two_dimension_array.max()) +print('mean: ',two_dimension_array.mean()) +# print('median: ', two_dimension_array.median()) +print('sd: ', two_dimension_array.std()) +``` + + min: 1 + max: 55 + mean: 14.777777777777779 + sd: 18.913709183069525 + + + +```python +print(two_dimension_array) +print('Column with minimum: ', np.amin(two_dimension_array,axis=0)) +print('Column with maximum: ', np.amax(two_dimension_array,axis=0)) +print('=== Row ==') +print('Row with minimum: ', np.amin(two_dimension_array,axis=1)) +print('Row with maximum: ', np.amax(two_dimension_array,axis=1)) +``` + + [[ 1 2 3] + [ 4 55 44] + [ 7 8 9]] + Column with minimum: [1 2 3] + Column with maximum: [ 7 55 44] + === Row == + Row with minimum: [1 4 7] + Row with maximum: [ 3 55 9] + + +## How to create repeating sequences? + + + +```python +a = [1,2,3] + +# Repeat whole of 'a' two times +print('Tile: ', np.tile(a, 2)) + +# Repeat each element of 'a' two times +print('Repeat: ', np.repeat(a, 2)) + +``` + + Tile: [1 2 3 1 2 3] + Repeat: [1 1 2 2 3 3] + + +## How to generate random numbers? + + +```python +# One random number between [0,1) +one_random_num = np.random.random() +one_random_in = np.random +print(one_random_num) +``` + + 0.4763968133790438 + + + +```python +# Random numbers between [0,1) of shape 2,3 +r = np.random.random(size=[2,3]) +print(r) +``` + + [[0.67018871 0.71699922 0.36490538] + [0.78086531 0.5779336 0.81444353]] + + + +```python +print(np.random.choice(['a', 'e', 'i', 'o', 'u'], size=10)) +``` + + ['i' 'u' 'e' 'o' 'a' 'i' 'e' 'u' 'o' 'i'] + + + +```python + +``` + + +```python +## Random numbers between [0, 1] of shape 2, 2 +rand = np.random.rand(2,2) +rand +``` + + + + + array([[0.66811333, 0.1139411 ], + [0.90955775, 0.14954203]]) + + + + +```python +rand2 = np.random.randn(2,2) +rand2 + +``` + + + + + array([[-0.84819546, -0.39626819], + [ 0.9172979 , 0.03661474]]) + + + + +```python +# Random integers between [0, 10) of shape 2,5 +rand_int = np.random.randint(0, 10, size=[5,3]) +rand_int +``` + + + + + array([[2, 7, 0], + [0, 2, 7], + [5, 9, 4], + [6, 0, 8], + [4, 6, 2]]) + + + + +```python + +``` + + +```python +from scipy import stats +np_normal_dis = np.random.normal(5, 0.5, 1000) +np_normal_dis +## min, max, mean, median, sd +print('min: ', np.min(np_normal_dis)) +print('max: ', np.max(np_normal_dis)) +print('mean: ', np.mean(np_normal_dis)) +print('median: ', np.median(np_normal_dis)) +print('mode: ', stats.mode(np_normal_dis)) +print('sd: ', np.std(np_normal_dis)) +``` + + min: 3.566493784430423 + max: 6.823091905048957 + mean: 5.034308251615374 + median: 5.0317142506545505 + mode: ModeResult(mode=array([3.56649378]), count=array([1])) + sd: 0.5050902240094916 + + + +```python +plt.hist(np_normal_dis, color="grey", bins=21) +``` + + + + + (array([ 3., 7., 11., 22., 41., 64., 72., 109., 117., 122., 117., + 93., 94., 47., 36., 20., 15., 5., 3., 0., 2.]), + array([3.56649378, 3.72156989, 3.87664599, 4.03172209, 4.18679819, + 4.34187429, 4.49695039, 4.65202649, 4.80710259, 4.96217869, + 5.11725479, 5.2723309 , 5.427407 , 5.5824831 , 5.7375592 , + 5.8926353 , 6.0477114 , 6.2027875 , 6.3578636 , 6.5129397 , + 6.6680158 , 6.82309191]), + ) + + + + +![png](numpy_files/numpy_108_1.png) + + + +```python +# numpy.dot(): Dot Product in Python using Numpy +# Dot Product +# Numpy is powerful library for matrices computation. For instance, you can compute the dot product with np.dot + +# Syntax + +# numpy.dot(x, y, out=None) +``` + + +```python +## Linear algebra +### Dot product: product of two arrays +f = np.array([1,2]) +g = np.array([4,5]) +### 1*4+2*5 +np.dot(f, g) +``` + + + + + 14 + + + + +```python +## Linear algebra +### Dot product: product of two arrays +f = np.array([1,2,3]) +g = np.array([4,5,3]) +### 1*4+2*5 + 3*6 +np.dot(f, g) +``` + + + + + 23 + + + + +```python +# NumPy Matrix Multiplication with np.matmul() +``` + + +```python +### Matmul: matruc product of two arrays +h = [[1,2],[3,4]] +i = [[5,6],[7,8]] +### 1*5+2*7 = 19 +np.matmul(h, i) +``` + + + + + array([[19, 22], + [43, 50]]) + + + + +```python +## Determinant 2*2 matrix +### 5*8-7*6np.linalg.det(i) +``` + + +```python +np.linalg.det(i) +``` + + + + + -1.999999999999999 + + + + +```python +Z = np.zeros((8,8)) +Z[1::2,::2] = 1 +Z[::2,1::2] = 1 +``` + + +```python +Z +``` + + + + + array([[0., 1., 0., 1., 0., 1., 0., 1.], + [1., 0., 1., 0., 1., 0., 1., 0.], + [0., 1., 0., 1., 0., 1., 0., 1.], + [1., 0., 1., 0., 1., 0., 1., 0.], + [0., 1., 0., 1., 0., 1., 0., 1.], + [1., 0., 1., 0., 1., 0., 1., 0.], + [0., 1., 0., 1., 0., 1., 0., 1.], + [1., 0., 1., 0., 1., 0., 1., 0.]]) + + + + +```python +new_list = [ x + 2 for x in range(0, 11)] +``` + + +```python +new_list +``` + + + + + [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] + + + + +```python +np_arr = np.array(range(0, 11)) +np_arr + 2 +``` + + + + + array([ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) + + + + +```python +x = np.array([1,2,3,4,5]) +y = x * 2 + 5 +y +``` + + + + + array([ 7, 9, 11, 13, 15]) + + + + +```python +plt.plot(x,y) +plt.xlabel('Temperature in oC') +plt.ylabel('Pressure in atm') +plt.title('Temperature vs Pressure') +plt.xticks(np.arange(0, 6, step=0.5)) +plt.show() +``` + + +![png](numpy_files/numpy_122_0.png) + + + +```python +x = np.random.normal(size=1000) +ax = sns.distplot(x); +ax.set(xlabel="x", ylabel='y') + +``` + + + + + [Text(0, 0.5, 'y'), Text(0.5, 0, 'x')] + + + + +![png](numpy_files/numpy_123_1.png) + + +# Summery + +To summarise, the main differences with python lists are: + +1. Arrays support vectorised operations, while lists don’t. +1. Once an array is created, you cannot change its size. You will have to create a new array or overwrite the existing one. +1. Every array has one and only one dtype. All items in it should be of that dtype. +1. An equivalent numpy array occupies much less space than a python list of lists. +1. numpy arrays support boolean indexing. diff --git a/numpy_files/numpy_108_1.png b/numpy_files/numpy_108_1.png new file mode 100644 index 0000000000000000000000000000000000000000..ade13cc6fba5a4009ed03876828c290cfcdfa94e GIT binary patch literal 5096 zcmbtYcT`hpqEDeHbs{1HQiKR22mvC+0YN2*ktW3j1p)|!p$8K>grGAJ6^VcXp;{=? zK{_T77o=ze1wuqxY*Z5v486SQ&hyRe&dmPt?m4&L@1A?kuYUL1IcsxKAsHb603eDy zgRlbtfRVi8ja>q~ElK3VMc$4NdkX2Wi?_t=@*?uicVo_6zybimd%mu~{xSR}@1gLg1ER<<>gfm+)?)|?S8 z4A4-twY#)sTQQCMx$e%7`|Iw1Otg6PD)of!-h#p_l8}2tLNY1AXN38@DzY^$gxfkL zkhep6Y2IYA;Yt_%_{#8#`f&A1&Q#vUM^1D8#^_YeQcg;9^D!vWTSg8COf9(M*==F> zL?jZamU$3{VnERsG#!+b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EIDpA3=H$q&*?+8Cvi+*$c2iW~jpZnBiyPkp9);u<#tnexXV9!K zbc%+OCb$=%iQ4kZ4$&~J=zh!dQk4ZmuJuk#DeQrHn12{_!4dNLDseRcVH90I z=W+&Nl;O9pmjtWkT%h?A%4W@YjnA>7NiV&W8nzd65wWSIq-Wl-UFJBJdVhOf6cXZt z$f1s`KZyV8J5l*>EV1J&hx|#zDL^71gSoMeLmYjJjRrAb_XXigAuQ-!F0<<%EsIX6 zK-FEFq)b^1q5QpCaSwJIKEI-~^qH6`zySsE;dRS@4r=5V2s0ou|f`a)sxBtlBaMN5c(!wz4Xq3fz00$ZRY(A(k#j zT18EaFz^731moqCU|TEcMV~U)4oK z<}rv6SF~QTBFm~|9C#3zg6Vw&6tK3U4}_X{^kW&aZw6nwK2-JF>SJXiD(Q47R7X*32IZ^b7WD#g(NTUn52!V_zoFH~ANA9H?Du+(bl&;l(_if7%OH z2+TlPqM`FFBbEjv#N+vTK2QRpZ8E?T(s+!UW@25yIE0>9@H;EA=m*xbgzcnp?^!A=rAx8CUN@wd-T?zHcTK}D*WyVT`a?pz&_Vp;NZq6~2Zdj3M9W!vO7HrK5f)nut~4?vM2fNM=V|@X zxjTkUUgKK`W4$A;YBSh!CR(p&)yR<=HWO}|ee`)mha4p29NJhYfUmOXr%tTCjohaE zL+`DZJX{Z&XV8MWZ_vimhxY<3?HWb3JKA#-q-ZA;!{qME4w`% x#x^)f=JoWH2YaX{a!uu-+K$=-2Do?pz`5$v#v6=t? literal 0 HcmV?d00001 diff --git a/numpy_files/numpy_122_0.png b/numpy_files/numpy_122_0.png new file mode 100644 index 0000000000000000000000000000000000000000..4c60471abf2a683d2b7bed024648f198aa0a3919 GIT binary patch literal 12639 zcmZ|02{@GR`#wC3UG`A+M3lX;g)AAe6lG0_$k-X{*tcX!$P&g{5?Qij8-@&uFqX(Z z!ysfEA`RKzXFi|r@BjP0|Koi-4o8l;?|Yv6x$kQ^&-1z@-ZQ$*#K6M<0)d$H^`Iso z5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tSS;owIrXWcD zfihn<*a$ZX^|g>qP>jV)EN#Ou%_r|pPq9@Ff7Hz}Jom&ckMi68xs~7D7n%>|zYt5= z(+*r1Zvj1kCI8(NONMSH{|(Lnu1uZ-G-(KP{?#DCz15qfYF-0>3<1*DF@jd#vXA+H E095IgIsgCw literal 0 HcmV?d00001 diff --git a/numpy_files/numpy_123_1.png b/numpy_files/numpy_123_1.png new file mode 100644 index 0000000000000000000000000000000000000000..020f20f3c3a23e7763fef26f3e5b7218d799b683 GIT binary patch literal 11080 zcmajF1yq&M*CtMPOSgoC2m;bb2-1jvN{3$h(%q%fA>Ab*-Ip$dduc@EB3!ytO1kFo zoB8Hj^ItRT?~9^;$KEO*Bd(zHXXJkJzi}8epAELn@XeF#I75~5uM1Lur$J=g2tgjwr$RW_I~OD zSB`!L?Njzw;lXtelDNmhq*h(N;=+0BK7m@1=d7rZfF86@&aKqs3C4@qnZfVn{!Qb$iIAP3*R+~^h){|1rS-m^ zmI7CB(BKGmj--nC!qO^Y3X)Naj#A?<*Nu|9g|M+e!>r>uE#`Oy4-Y!NfN;}?dYJdo zKWUU8De=;pQzmR>t6p5%I5g%V;l{RUQz$oEGY5V*f6-s6csHZG2|5$(e9?o zr_CA>f%mC>nN0B)f9?kxzOE%v&IZEmSFwE;x~vg=k?`x`p%z*Qp> zcWTxk8d11R$-|gI^ufy9d}0nh zF;9pNkJ8TPNb@SZ$spT#pa^t=>SkMG9pKzqUfF\%BJUY`TMckn0Wk- zJZm3H2pap9Omb6t2J{<&uFPHdg0~ z!48Erv7E8(3+*%S$G}b;AVY-k^h=@RHns{?j>HZR*NEw;cb*=|>J|qFOMEajD|_An z1_aJ;Le)bqztCC+i-x^oO!#OoZkZ|d26M$dDQtwEby$UuE1yH1?y=#S@;f~ zY|uIeOINccQ#qwU5PcaRHfM^O%i)YTu+@{_GiN$uu{$<3B`}#jFSD)B?Lk8CsiInx zLs+p_e{Jw32@~2o)xcelGVmT3Mj2->_6aIZ|6N=}Mn<${ts1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Y+fB4Yh2U45(f9n| zA@tN=cF#*-CwXm#wAf^LlS1&KO4wAVJveb7IEwzAkKeMqaNaVNKE=%XKu8iGO?&VAsBu~a(Ey5P7Z&@cXv zGl_u7lP7TAouov+J2P0Xh&itK%fi+-I%sg|A2-he)52{N@+PC=V`OClPDx}D*gaGa z$4erPN|;u=abjQQCXqZxXJB-1|Go9#PX0+YSM}dvtcj+?d?V|+y-V~2Y!V7-F^a!_ z(CYqJ;wuHqHQy%e!A*TbdavJCQh`i0PZlez5;k9pyup7wup|`8CLwQqcY<<*2uu_R iR*L`s=Nx-(afVao58oEGID=EKXsXX&C{{l+5B(p^eRb{t literal 0 HcmV?d00001 diff --git a/readme19-21.md b/readme19-21.md index 91c396bd..dd9669a7 100644 --- a/readme19-21.md +++ b/readme19-21.md @@ -1207,7 +1207,7 @@ We can use super() function or the parent name Person to automatically inherit t ## πŸ’» Exercises: Day 21 -1. Python has the module called _statistics_ and we can use this module to do all the statistical caluculations. Hower to challlenge ourselves, let's try to develop a program which calculate measure of central tendency of a sample(mean, median, mode) and measure of variability(range, variance, standard deviation). In addition to those measures(mean, mode and median), find the min, max, count, percentile, and frequency distribution of the sample. You can create a class called Statistics and create all the functions which do statistical calculations as method for the Statistics class. Check the output below. +1. Python has the module called _statistics_ and we can use this module to do all the statistical caluculations. Hower to challlenge ourselves, let's try to develop a program which calculate measure of central tendency of a sample(mean, median, mode) and measure of variability(range, variance, standard deviation). In addition to those measures find the min, max, count, percentile, and frequency distribution of the sample. You can create a class called Statistics and create all the functions which do statistical calculations as method for the Statistics class. Check the output below. ```py ages = [31, 26, 34, 37, 27, 26, 32, 32, 26, 27, 27, 24, 32, 33, 27, 25, 26, 38, 37, 31, 34, 24, 33, 29, 26] diff --git a/readme22-24.md b/readme22-24.md index bfd6cf9f..da48fe93 100644 --- a/readme22-24.md +++ b/readme22-24.md @@ -12,13 +12,40 @@ 🧳 [Part 10: Day 28 - 30](#) πŸ”’ --- + - [πŸ“˜ Day 22](#%f0%9f%93%98-day-22) - [Python Web Scraping](#python-web-scraping) - [What is web scrapping](#what-is-web-scrapping) - [πŸ’» Exercises: Day 22](#%f0%9f%92%bb-exercises-day-22) - [πŸ“˜ Day 23](#%f0%9f%93%98-day-23) - [Setting up Virtual Environments](#setting-up-virtual-environments) - - [πŸ’» Exercises: Day 23](#%f0%9f%92%bb-exercises-day-23) +- [How to import numpy](#how-to-import-numpy) +- [How to check the version of the numpy package](#how-to-check-the-version-of-the-numpy-package) +- [Checking the available methods](#checking-the-available-methods) +- [Creating python List](#creating-python-list) +- [Checking data types](#checking-data-types) +- [Creating Numpy(Numerical Python) array from python list](#creating-numpynumerical-python-array-from-python-list) +- [We can always convert an array back to a python list using tolist().](#we-can-always-convert-an-array-back-to-a-python-list-using-tolist) +- [Numpy array from tuple](#numpy-array-from-tuple) +- [Creating tuple in Python](#creating-tuple-in-python) +- [Mathematical Operation](#mathematical-operation) +- [Addition](#addition) +- [Multiplication](#multiplication) +- [Converting type from float to int](#converting-type-from-float-to-int) +- [Converting type from int to str](#converting-type-from-int-to-str) +- [2 Dimension Array](#2-dimension-array) +- [2 Dimension Array](#2-dimension-array-1) + - [Reverse only the row positions](#reverse-only-the-row-positions) + - [Reverse the row and column positions](#reverse-the-row-and-column-positions) + - [How to represent missing values and infinite?](#how-to-represent-missing-values-and-infinite) + - [Generating Random Numbers](#generating-random-numbers) + - [Numpy and Statistics](#numpy-and-statistics) + - [NumPy Statistical Functions with Example](#numpy-statistical-functions-with-example) + - [How to create repeating sequences?](#how-to-create-repeating-sequences) + - [How to generate random numbers?](#how-to-generate-random-numbers) +- [Summery](#summery) + - [πŸ’» Exercises: Day 24](#%f0%9f%92%bb-exercises-day-24) + # πŸ“˜ Day 22 ## Python Web Scraping @@ -89,45 +116,59 @@ table = tables[0] # the result is list, we are taking out from the list for td in table.find('tr').find_all('td'): print(td.text) ``` + If you run the above code, you can see that the extraction is half done. You can continue doing it because it is part of exercise 1. For reference check the beautiful [soup documentation](https://www.crummy.com/software/BeautifulSoup/bs4/doc/#quick-start) - ## πŸ’» Exercises: Day 22 + 1. Extract the table in this url (http://mlr.cs.umass.edu/ml/datasets.html) and change it to a json file 2. Scrape the presidents table and store the data as json(https://en.wikipedia.org/wiki/List_of_presidents_of_the_United_States) # πŸ“˜ Day 23 + ## Setting up Virtual Environments + To start with project, it would be better to have a virtual environment. Virtual environment can help us to create an isolated or separate environment. This will help us to avoid conflicts in dependencies across projects. If you write pip freeze on your terminal you will see all the installed packages on your computer. If we use virtualenv, we will access only packages which are specific for that project. Open your terminal and install virtualenv + ```sh asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ pip install virtualenv ``` + After installing the virtualenv package go to your project folder and create a virtual env by writing: ``sh -asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ virtualenv venv -``` +asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project\$ virtualenv venv + +```` The venv name could another name too but I prefer to call it venv. Let's check if the the venv is create by using ls command. ```sh asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ ls venv/ -``` -Let's activate the virtual environment by writing the following command at our project folder. +```` + +Let's activate the virtual environment by writing the following command at our project folder. + ```sh asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ source venv/bin/activate ``` + After you write the activation command, your project directory will start with venv. See the example below. + ```sh -(venv) asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ +(venv) asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ ``` -Now, lets check the available package in this project by writing pip freeze. You will not see any package. + +Now, lets check the available package in this project by writing pip freeze. You will not see any package. We are going to do a small flask project so let's install flask to this project. + ```sh (venv) asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ pip install Flask ``` + Now, let's write pip freeze to see the install packages in the project + ```sh (venv) asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ pip freeze Click==7.0 @@ -137,17 +178,1051 @@ Jinja2==2.10.3 MarkupSafe==1.1.1 Werkzeug==0.16.0 ``` -When you finish you should dactivate active project using *deactivate*. + +When you finish you should dactivate active project using _deactivate_. + ```sh (venv) asabeneh@Asabeneh:~/Desktop/30DaysOfPython$ deactivate ``` -The necessary modules to work on flask are installed. Now, you project directory is ready for flask project. You should include the venv to your .gitignore file not to push it to github. +The necessary modules to work on flask are installed. Now, you project directory is ready for flask project. You should include the venv to your .gitignore file not to push it to github. ## πŸ’» Exercises: Day 23 -1. Create a project directory with a virtual environment based on the example give above. - + 1. Create a project directory with a virtual environment based on the example give above. +# Day 24 + +## Python for Statistical Analysis + +### Statistics + +Statistics is the discipline that concerns the _collection_, _organization_, _displaying_, _analysis_, _interpretation_ and _presentation_ of data. +Statistics is a sub field of mathematics that is universally agreed to be a prerequisite for a deeper understanding of data science and machine learning. Statistics is a very broad field but we will focus in this section only on the most relevant part. +After completing this challenge, you may go to web development, data analysis, machine learning and data science path. Whatever path you may follow, at some point you will in your career you will get data which you may work on. + +### Data + +What is data? Data is any set of characters that is gathered and translated for some purpose, usually analysis. It can be any character, including text and numbers, pictures, sound, or video. If data is not put into context, it doesn't do anything to a human or computer. To make sense from data we need to work on the data using different tools. +The work flow of data analysis, data science or machine learning starts from data. +Either we create or get data. Data can be found as small or big data format. Most of the data types we will get have been covered in the file handling section. + +### Statistics Module + +The python _statistics_ module provides functions for calculating mathematical statistics of numeric data. The module is not intended to be a competitor to third-party libraries such as NumPy, SciPy, or proprietary full-featured statistics packages aimed at professional statisticians such as Minitab, SAS and Matlab. It is aimed at the level of graphing and scientific calculators. + +## NumPy + +In the first section we defined python as a great general-purpose programming language on its own, but with the help of other popular libraries (numpy, scipy, matplotlib, pandas etc) it becomes a powerful environment for scientific computing. + +Numpy is the core library for scientific computing in Python. It provides a high-performance multidimensional array object, and tools for working with arrays. + +So far, we have been using vscode but from now on I would recommend using Jupyter Notebook. To access jupter notebook let's install [anaconda](https://www.anaconda.com/). If you are using anaconda most of the common packages are included and you don't have install packages if you installed anaconda. + +```sh +asabeneh@Asabeneh:~/Desktop/30DaysOfPython$ pip install numpy +``` + +### Importing NumPy + +Jupyter notebook is available if your are in favor of [jupyter notebook](https://github.com/Asabeneh/30-Days-Of-Python/blob/master/r) + +```py +# How to import numpy +import numpy as np +# How to check the version of the numpy package +print('numpy:', np.__version__) +# Checking the available methods +print(dir(np)) +``` + +### Creating numpy array using + +```py +# Creating python List +python_list = [1,2,3,4,5] +# Checking data types +print(type (python_list)) +print(python_list) +two_dimensional_list = [[0,1,2], [3,4,5], [6,7,8]] +print(two_dimensional_list) +``` + +```sh + +[1 2 3 4 5] +``` + +```py +# Creating Numpy(Numerical Python) array from python list +numpy_array_from_list = np.array(python_list) +print(type (numpy_array_from_list)) +print(numpy_array_from_list) +``` + +Creating list with a float data type + +```py +python_list = [1,2,3,4,5] +numy_array_from_list2 = np.array(python_list, dtype=float) +print(numy_array_from_list2) +``` + +```sh +array([1., 2., 3., 4., 5.]) +``` + +Creating list with a boolean data type + +```py +numpy_bool_array = np.array([0, 1, -1, 0, 0], dtype=bool) +print(numpy_bool_array) +``` + +```sh +array([False, True, True, False, False]) +``` + +Creating multidimensional array using numpy + +```py +two_dimensional_list = [[0,1,2], [3,4,5], [6,7,8]] +numpy_two_dimensional_list = np.array(two_dimensional_list) +print(type (numpy_two_dimensional_list)) +print(numpy_two_dimensional_list) +``` + +```sh +array([[0, 1, 2], + [3, 4, 5], + [6, 7, 8]]) +``` + +### Converting numpy array to list + +```py +# We can always convert an array back to a python list using tolist(). +np_to_list = numpy_array_from_list.tolist() +print(type (np_to_list)) +print('one dimensional array:', np_to_list) +print('two dimensional array: ', numpy_two_dimensional_list.tolist()) +``` + +```sh + +one dimensional array: [1, 2, 3, 4, 5] +two dimensional array: [[0, 1, 2], [3, 4, 5], [6, 7, 8]] +``` + +### Creating numpy array from tuple + +```py +# Numpy array from tuple +# Creating tuple in Python + +python_tuple = (1,2,3,4,5) +print(type (python_tuple)) +print('python_tuple: ', python_tuple) + +numpy_array_from_tuple = np.array(python_tuple) +print(type (numpy_array_from_tuple)) +print('numpy_array_from_tuple: ', numpy_array_from_tuple) +``` + +```sh + +python_tuple: (1, 2, 3, 4, 5) + +numpy_array_from_tuple: array([1, 2, 3, 4, 5]) +``` + +### Shape of numpy array + +The shape method provide the shape of the array as a tuple. The first is the row and the second is the column + +```py +nums = np.array([1, 2, 3, 4, 5]) +print(nums) +print('shape of nums: ', nums.shape) +print(numpy_two_dimensional_list) +print('shape of numpy_two_dimensional_list: ', numpy_two_dimensional_list.shape) +three_by_four_array = np.array([[0, 1, 2, 3], + [4,5,6,7], + [8,9,10, 11]]) +print(three_by_four_array.shape) +``` + +```sh +[1 2 3 4 5] +shape of nums: (5,) +[[0 1 2] +[3 4 5] +[6 7 8]] +shape of numpy_two_dimensional_list: (3, 3) +(3, 4) +``` + +### Data type of numpy array + +Type of data types: str, int, float, complex, bool, list, None + +```py +int_lists = [-3, -2, -1, 0, 1, 2,3] +int_array = np.array(int_lists) +float_array = np.array(int_lists, dtype=float) + +print(int_array) +print(int_array.dtype) +print(float_array) +print(float_array.dtype) +``` + +```sh +[-3 -2 -1 0 1 2 3] +int64 +[-3. -2. -1. 0. 1. 2. 3.] +float64 +``` + +### Size of a numpy arrayΒΆ + +Instead of len size is used to get the length of items in a numpy array + +```py +numpy_array_from_list = np.array([1, 2, 3, 4, 5]) +two_dimensional_list = np.array([[0, 1, 2], + [3, 4, 5], + [6, 7, 8]]) +print(len(numpy_array_from_list)) # 5 +print(len(two_dimensional_list)) # 3 +``` + +### Mathematical Operation + +```py +# Mathematical Operation +# Addition +print('original array: ', numpy_array_from_list) +ten_plus_original = numpy_array_from_list + 10 +print(ten_plus_original) +ten_minus_original = numpy_array_from_list - 10 +print(ten_minus_original) +# Multiplication +ten_times_original = numpy_array_from_list * 10 +print(ten_times_original) +``` + +```sh +original array: [1 2 3 4 5] +[11 12 13 14 15] +[-9 -8 -7 -6 -5] +[10 20 30 40 50] +``` + +### Checking numpy array data types + +```py +#Int, Float numbers + +numpy_int_list = np.array([1,2,3,4]) +numpy_float_list = np.array([1.1, 2.0,3.2]) +numpy_float_list2 = np.array([1.1,2.0,3.2]) + +print(numpy_int_list.dtype) +print(numpy_float_list2.dtype) +print(numpy_float_list.dtype) +``` + +```sh +int64 +float64 +float64 +``` + +### Converting types + +```py +# Converting type from float to int +numpy_float_list = np.array([1.1, 2.0,3.2]) +numpy_float_list.astype('int') +print(numpy_float_list) +``` + +```sh +array([1, 2, 3]) +``` + +```py +# Converting type from int to str +numpy_float_list.astype('int').astype('str') +``` + +```sh +array(['1', '2', '3'], dtype=' +[[1 2 3] + [4 5 6] + [7 8 9]] +Shape: (3, 3) +Size: 9 +Data type: int64 +``` + +### Getting items from a numpy array + +```py +# 2 Dimension Array +two_dimension_array = np.array([[1,2,3],[4,5,6], [7,8,9]]) +first_row = two_dimension_array[0] +second_row = two_dimension_array[1] +third_row = two_dimension_array[2] +print('First row:', first_row) +print('Second row:', second_row) +print('Third row: ', third_row) +``` + +```sh +First row: [1 2 3] +Second row: [4 5 6] +Third row: [7 8 9] +``` + +```py +first_column= two_dimension_array[:,0] +second_column = two_dimension_array[:,1] +third_column = two_dimension_array[:,2] +print('First column:', first_column) +print('Second column:', second_column) +print('Third column: ', third_column) +print(two_dimension_array) + +``` + +```sh +First column: [1 4 7] +Second column: [2 5 8] +Third column: [3 6 9] +[[1 2 3] + [4 5 6] + [7 8 9]] +``` + +Slicing in numpy is similar to slicing in python list + +```py +first_two_rows_and_columns = two_dimension_array[0:2, 0:2] +print(first_two_rows_and_columns) +``` + +```sh +array([[1, 2], + [4, 5]]) +``` + +### How to reverse the rows and the whole array? + +````python +two_dimension_array[::] + array([[1, 2, 3], + [4, 5, 6], + [7, 8, 9]]) + + +### Reverse only the row positions + + +```python +two_dimension_array[::-1,] +```` + + array([[7, 8, 9], + [4, 5, 6], + [1, 2, 3]]) + +### Reverse the row and column positions + +```python +two_dimension_array[::-1,::-1] +``` + + array([[9, 8, 7], + [6, 5, 4], + [3, 2, 1]]) + +## How to represent missing values and infinite? + +```python +print(two_dimension_array) +two_dimension_array[1,1] = 55 +two_dimension_array[1,2] =44 +print(two_dimension_array) +``` + + [[1 2 3] + [4 5 6] + [7 8 9]] + [[ 1 2 3] + [ 4 55 44] + [ 7 8 9]] + +```python +# Numpy Zeroes +# numpy.zeros(shape, dtype=float, order='C') +numpy_zeroes = np.zeros((3,3),dtype=int,order='C') +numpy_zeroes +``` + + array([[0, 0, 0], + [0, 0, 0], + [0, 0, 0]]) + +```python +# Numpy Zeroes +numpy_ones = np.ones((3,3),dtype=int,order='C') +print(numpy_ones) +``` + + [[1 1 1] + [1 1 1] + [1 1 1]] + +```python +twoes = numpy_ones * 2 +``` + +```python +# Reshape +# numpy.reshape(), numpy.flatten() +first_shape = np.array([(1,2,3), (4,5,6)]) +print(first_shape) +reshaped = first_shape.reshape(3,2) +print(reshaped) + +``` + + [[1 2 3] + [4 5 6]] + [[1 2] + [3 4] + [5 6]] + +```python +flattened = reshaped.flatten() +flattened +``` + + array([1, 2, 3, 4, 5, 6]) + +```python +## Horitzontal Stack +np_list_one = np.array([1,2,3]) +np_list_two = np.array([4,5,6]) + +print(np_list_one + np_list_two) + +print('Horizontal Append:', np.hstack((np_list_one, np_list_two))) +``` + + [5 7 9] + Horizontal Append: [1 2 3 4 5 6] + +```python +## Vertical Stack +print('Vertical Append:', np.vstack((np_list_one, np_list_two))) +``` + + Vertical Append: [[1 2 3] + [4 5 6]] + +#### Generating Random Numbers + +```python +# Generate a random float number +random_float = np.random.random() +random_float +``` + + 0.6661632875670657 + +```python +# Generate a random float number +random_floats = np.random.random(5) +random_floats +``` + + array([0.12945387, 0.1859908 , 0.47805876, 0.51996342, 0.52458233]) + +```python +# Generating a random integers between 0 and 10 +random_int = np.random.randint(0, 11) +random_int +``` + + 7 + +```python +# Generating a random integers between 2 and 11, and creating a one row array +random_int = np.random.randint(2,10, size=4) +random_int +``` + + array([5, 8, 8, 9]) + +```python +# Generating a random integers between 0 and 10 +random_int = np.random.randint(2,10, size=(3,3)) +random_int +``` + + array([[8, 9, 5], + [9, 8, 3], + [2, 3, 8]]) + +```python +# Generate random numbers +# np.random.normal(mu, sigma, size) +normal_array = np.random.normal(79, 15, 80) +normal_array + +``` + + array([ 76.67233671, 87.8686846 , 64.80771996, 79.44136527, + 68.83066184, 102.85967631, 74.40838573, 58.56053793, + 93.76814784, 82.16082568, 86.80548555, 77.95291907, + 97.71514434, 95.94083876, 82.53018033, 73.74619803, + 67.07970869, 102.20984782, 81.67766599, 73.82096132, + 90.17632538, 102.87342877, 84.19855251, 81.11888938, + 63.42782472, 75.3734846 , 79.04423914, 56.52607352, + 58.30505483, 54.69555571, 63.25792739, 88.75239018, + 85.44533248, 59.76883843, 39.72683784, 78.1029094 , + 54.19952262, 82.383277 , 87.01010766, 73.09642208, + 81.99276776, 82.58990091, 72.71303439, 101.73499367, + 73.65596295, 81.89611334, 96.14703307, 74.9629613 , + 84.79491744, 90.77830881, 70.69085365, 69.27799996, + 74.07836137, 56.79410721, 76.08072393, 83.28246182, + 83.66382654, 80.79644627, 83.39674788, 73.68044176, + 59.74405724, 47.50763054, 50.99870066, 85.53776901, + 80.61131428, 62.66726385, 69.8289171 , 58.2394869 , + 86.5158869 , 86.92976422, 65.12965299, 101.9918336 , + 73.3855881 , 99.29788439, 82.48238578, 83.14592314, + 109.13987986, 87.18461073, 73.18647475, 76.04712709, + + ]) + +## Numpy and Statistics + +```python +import matplotlib.pyplot as plt +import seaborn as sns +sns.set() +plt.hist(normal_array, color="grey", bins=50) +``` + + (array([ 1., 0., 1., 2., 0., 1., 3., 3., 4., 2., 4., 10., 7., + 12., 15., 13., 20., 26., 16., 32., 36., 42., 38., 37., 35., 54., + 50., 40., 40., 55., 56., 49., 45., 29., 37., 26., 26., 23., 28., + 12., 22., 10., 11., 5., 3., 6., 4., 4., 3., 2.]), + array([ 26.42484343, 28.2913796 , 30.15791576, 32.02445192, + 33.89098809, 35.75752425, 37.62406041, 39.49059657, + 41.35713274, 43.2236689 , 45.09020506, 46.95674123, + 48.82327739, 50.68981355, 52.55634972, 54.42288588, + 56.28942204, 58.1559582 , 60.02249437, 61.88903053, + 63.75556669, 65.62210286, 67.48863902, 69.35517518, + 71.22171134, 73.08824751, 74.95478367, 76.82131983, + 78.687856 , 80.55439216, 82.42092832, 84.28746449, + 86.15400065, 88.02053681, 89.88707297, 91.75360914, + 93.6201453 , 95.48668146, 97.35321763, 99.21975379, + 101.08628995, 102.95282611, 104.81936228, 106.68589844, + 108.5524346 , 110.41897077, 112.28550693, 114.15204309, + 116.01857926, 117.88511542, 119.75165158]), + ) + +```python + +``` + +```python +# numpy.asarray() +# Asarray +# The asarray()function is used when you want to convert an input to an array. +# The input could be a lists, tuple, ndarray, etc. +``` + +```python +four_by_four_matrix = np.matrix(np.ones((4,4), dtype=float)) +``` + +```python +four_by_four_matrix +``` + + matrix([[1., 1., 1., 1.], + [1., 1., 1., 1.], + [1., 1., 1., 1.], + [1., 1., 1., 1.]]) + +```python +np.asarray(four_by_four_matrix)[2] = 2 +four_by_four_matrix +``` + + matrix([[1., 1., 1., 1.], + [1., 1., 1., 1.], + [2., 2., 2., 2.], + [1., 1., 1., 1.]]) + +```python +# numpy.arange() in Python with Example +# Whay is Arrange? +# Sometimes, you want to create values that are evenly spaced within a defined interval. +# For instance, you want to create values from 1 to 10; you can use numpy.arange() function + +``` + +```python +# creating list using range(starting, stop, step) +lst = range(0, 11, 2) +lst +``` + + range(0, 11, 2) + +```python +for l in lst: + print(l) +``` + + 0 + 2 + 4 + 6 + 8 + 10 + +```python +# Similar to range arange numpy.arange(start, stop, step) +whole_numbers = np.arange(0, 20, 1) +whole_numbers +``` + + array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19]) + +```python +natural_numbers = np.arange(1, 20, 1) +natural_numbers +``` + + array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19]) + +```python +odd_numbers = np.arange(1, 20, 2) +odd_numbers +``` + + array([ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) + +```python +even_numbers = np.arange(2, 20, 2) +even_numbers +``` + + array([ 2, 4, 6, 8, 10, 12, 14, 16, 18]) + +```python +# numpy.linspace() +# numpy.logspace() in Python with Example +# For instance, it can be used to create 10 values from 1 to 5 evenly spaced. +np.linspace(1.0, 5.0, num=10) +``` + + array([1. , 1.44444444, 1.88888889, 2.33333333, 2.77777778, + 3.22222222, 3.66666667, 4.11111111, 4.55555556, 5. ]) + +```python +# not to include the last value in the interval +np.linspace(1.0, 5.0, num=5, endpoint=False) +``` + + array([1. , 1.8, 2.6, 3.4, 4.2]) + +```python +# LogSpace +# LogSpace returns even spaced numbers on a log scale. Logspace has the same parameters as np.linspace. + +# Syntax: + +# numpy.logspace(start, stop, num, endpoint) +``` + +```python +np.logspace(2, 4.0, num=4) +``` + + array([ 100. , 464.15888336, 2154.43469003, 10000. ]) + +```python +# to check the size of an array +x = np.array([1,2,3], dtype=np.complex128) +``` + +```python +x +``` + + array([1.+0.j, 2.+0.j, 3.+0.j]) + +```python +x.itemsize +``` + + 16 + +```python +# indexing and Slicing NumPy Arrays in Python +np_list = np.array([(1,2,3), (4,5,6)]) +np_list + +``` + + array([[1, 2, 3], + [4, 5, 6]]) + +```python +print('First row: ', np_list[0]) +print('Second row: ', np_list[1]) + +``` + + First row: [1 2 3] + Second row: [4 5 6] + +```python +print('First column: ', np_list[:,0]) +print('Second column: ', np_list[:,1]) +print('Third column: ', np_list[:,2]) + +``` + + First column: [1 4] + Second column: [2 5] + Third column: [3 6] + +### NumPy Statistical Functions with Example + +NumPy has quite a few useful statistical functions for finding minimum, maximum, percentile standard deviation and variance, etc from the given elements in the array. +The functions are explained as follows βˆ’ +Statistical function +Numpy is equipped with the robust statistical function as listed below + +- Numpy Functions + - Min np.min() + - Max np.max() + - Mean np.mean() + - Median np.median() + - Standard deviation np.std() + +```python +np_normal_dis = np.random.normal(5, 0.5, 100) +np_normal_dis +## min, max, mean, median, sd +print('min: ', two_dimension_array.min()) +print('max: ', two_dimension_array.max()) +print('mean: ',two_dimension_array.mean()) +# print('median: ', two_dimension_array.median()) +print('sd: ', two_dimension_array.std()) +``` + + min: 1 + max: 55 + mean: 14.777777777777779 + sd: 18.913709183069525 + +```python +print(two_dimension_array) +print('Column with minimum: ', np.amin(two_dimension_array,axis=0)) +print('Column with maximum: ', np.amax(two_dimension_array,axis=0)) +print('=== Row ==') +print('Row with minimum: ', np.amin(two_dimension_array,axis=1)) +print('Row with maximum: ', np.amax(two_dimension_array,axis=1)) +``` + + [[ 1 2 3] + [ 4 55 44] + [ 7 8 9]] + Column with minimum: [1 2 3] + Column with maximum: [ 7 55 44] + === Row == + Row with minimum: [1 4 7] + Row with maximum: [ 3 55 9] + +### How to create repeating sequences? + +```python +a = [1,2,3] + +# Repeat whole of 'a' two times +print('Tile: ', np.tile(a, 2)) + +# Repeat each element of 'a' two times +print('Repeat: ', np.repeat(a, 2)) + +``` + + Tile: [1 2 3 1 2 3] + Repeat: [1 1 2 2 3 3] + +### How to generate random numbers? + +```python +# One random number between [0,1) +one_random_num = np.random.random() +one_random_in = np.random +print(one_random_num) +``` + + 0.4763968133790438 + +```python +# Random numbers between [0,1) of shape 2,3 +r = np.random.random(size=[2,3]) +print(r) +``` + + [[0.67018871 0.71699922 0.36490538] + [0.78086531 0.5779336 0.81444353]] + +```python +print(np.random.choice(['a', 'e', 'i', 'o', 'u'], size=10)) +``` + + ['i' 'u' 'e' 'o' 'a' 'i' 'e' 'u' 'o' 'i'] + +```python + +``` + +```python +## Random numbers between [0, 1] of shape 2, 2 +rand = np.random.rand(2,2) +rand +``` + + array([[0.66811333, 0.1139411 ], + [0.90955775, 0.14954203]]) + +```python +rand2 = np.random.randn(2,2) +rand2 + +``` + + array([[-0.84819546, -0.39626819], + [ 0.9172979 , 0.03661474]]) + +```python +# Random integers between [0, 10) of shape 2,5 +rand_int = np.random.randint(0, 10, size=[5,3]) +rand_int +``` + + array([[2, 7, 0], + [0, 2, 7], + [5, 9, 4], + [6, 0, 8], + [4, 6, 2]]) + +```python + +``` + +```python +from scipy import stats +np_normal_dis = np.random.normal(5, 0.5, 1000) +np_normal_dis +## min, max, mean, median, sd +print('min: ', np.min(np_normal_dis)) +print('max: ', np.max(np_normal_dis)) +print('mean: ', np.mean(np_normal_dis)) +print('median: ', np.median(np_normal_dis)) +print('mode: ', stats.mode(np_normal_dis)) +print('sd: ', np.std(np_normal_dis)) +``` + + min: 3.566493784430423 + max: 6.823091905048957 + mean: 5.034308251615374 + median: 5.0317142506545505 + mode: ModeResult(mode=array([3.56649378]), count=array([1])) + sd: 0.5050902240094916 + +```python +plt.hist(np_normal_dis, color="grey", bins=21) +``` + + (array([ 3., 7., 11., 22., 41., 64., 72., 109., 117., 122., 117., + 93., 94., 47., 36., 20., 15., 5., 3., 0., 2.]), + array([3.56649378, 3.72156989, 3.87664599, 4.03172209, 4.18679819, + 4.34187429, 4.49695039, 4.65202649, 4.80710259, 4.96217869, + 5.11725479, 5.2723309 , 5.427407 , 5.5824831 , 5.7375592 , + 5.8926353 , 6.0477114 , 6.2027875 , 6.3578636 , 6.5129397 , + 6.6680158 , 6.82309191]), + ) + +![png](numpy_files/numpy_108_1.png) + +```python +# numpy.dot(): Dot Product in Python using Numpy +# Dot Product +# Numpy is powerful library for matrices computation. For instance, you can compute the dot product with np.dot + +# Syntax + +# numpy.dot(x, y, out=None) +``` + +```python +## Linear algebra +### Dot product: product of two arrays +f = np.array([1,2]) +g = np.array([4,5]) +### 1*4+2*5 +np.dot(f, g) +``` + + 14 + +```python +## Linear algebra +### Dot product: product of two arrays +f = np.array([1,2,3]) +g = np.array([4,5,3]) +### 1*4+2*5 + 3*6 +np.dot(f, g) +``` + + 23 + +```python +# NumPy Matrix Multiplication with np.matmul() +``` + +```python +### Matmul: matruc product of two arrays +h = [[1,2],[3,4]] +i = [[5,6],[7,8]] +### 1*5+2*7 = 19 +np.matmul(h, i) +``` + + array([[19, 22], + [43, 50]]) + +```python +## Determinant 2*2 matrix +### 5*8-7*6np.linalg.det(i) +``` + +```python +np.linalg.det(i) +``` + + -1.999999999999999 + +```python +Z = np.zeros((8,8)) +Z[1::2,::2] = 1 +Z[::2,1::2] = 1 +``` + +```python +Z +``` + + array([[0., 1., 0., 1., 0., 1., 0., 1.], + [1., 0., 1., 0., 1., 0., 1., 0.], + [0., 1., 0., 1., 0., 1., 0., 1.], + [1., 0., 1., 0., 1., 0., 1., 0.], + [0., 1., 0., 1., 0., 1., 0., 1.], + [1., 0., 1., 0., 1., 0., 1., 0.], + [0., 1., 0., 1., 0., 1., 0., 1.], + [1., 0., 1., 0., 1., 0., 1., 0.]]) + +```python +new_list = [ x + 2 for x in range(0, 11)] +``` + +```python +new_list +``` + + [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] + +```python +np_arr = np.array(range(0, 11)) +np_arr + 2 +``` + + array([ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) + +```python +x = np.array([1,2,3,4,5]) +y = x * 2 + 5 +y +``` + + array([ 7, 9, 11, 13, 15]) + +```python +plt.plot(x,y) +plt.xlabel('Temperature in oC') +plt.ylabel('Pressure in atm') +plt.title('Temperature vs Pressure') +plt.xticks(np.arange(0, 6, step=0.5)) +plt.show() +``` + +![png](numpy_files/numpy_122_0.png) + +```python +x = np.random.normal(size=1000) +ax = sns.distplot(x); +ax.set(xlabel="x", ylabel='y') + +``` + + [Text(0, 0.5, 'y'), Text(0.5, 0, 'x')] + +![png](numpy_files/numpy_123_1.png) + +# Summery + +To summarise, the main differences with python lists are: + +1. Arrays support vectorised operations, while lists don’t. +1. Once an array is created, you cannot change its size. You will have to create a new array or overwrite the existing one. +1. Every array has one and only one dtype. All items in it should be of that dtype. +1. An equivalent numpy array occupies much less space than a python list of lists. +1. numpy arrays support boolean indexing. + +## πŸ’» Exercises: Day 24 +1. Repeat all the examples + [<< Part 7 ](https://github.com/Asabeneh/30-Days-Of-Python/blob/master/readme19-21.md) | [Part 9 >>](https://github.com/Asabeneh/30-Days-Of-Python/blob/master/readme25-27.md) ---- \ No newline at end of file +---