8 – Sort an Array Sorting of an Array¶ In [2]: import numpy as np In [3]: import numpy as np arr = np.array([[30,17,15],[19,90,16],[69,53,21]]) arr Out[3]: array([[30, 17, 15], [19, 90, 16], [69, 53, 21]]) sort an array along a specified axis¶ In [4]: # sort along the row and return a copy …
Read More »Numpy Slicing & Indexing
7 – Slicing & Indexing Subset, Slice, Index and Iterate through Arrays¶For one-dimensional arrays, indexing, slicing etc. is similar to python lists – indexing starts at 0. Slicing arrays¶Slicing in python means taking elements from one given index to another given index. We pass slice instead of index like this: …
Read More »Numpy Mathematic Functions
6 – Math Functions NumPy Math Functions¶ In [2]: import numpy as np In [3]: arr = np.random.randint(10,99,[3,3]) arr Out[3]: array([[45, 53, 78], [81, 88, 25], [71, 55, 59]]) Element-wise addition, subtraction, multiplication and division¶ In [4]: print(arr + 10) print(arr - 10) print(arr * 10) print(arr / 10) [[55 63 88] [91 …
Read More »Numpy Random Array
5 – Random Array NumPy Random Array¶ In [2]: import numpy as np In [3]: # generate a random scalar print(np.random.rand()) 0.2224104911171324 In [4]: # generate a 1-D array print(np.random.rand(3)) [0.69589689 0.9990713 0.77034202] In [5]: # generate a 2-D array print(np.random.rand(3,3)) [[0.2151302 0.64925559 0.95982155] [0.02673682 0.33937101 0.78181161] [0.39285799 0.7581885 0.15635241]] Generate a sample from …
Read More »Inspect an Array
4 – Inspect an Array Inspect NumPy Array¶ In [2]: import numpy as np In [3]: arr = np.array([[1,2,3], [4,5,6]], dtype=np.int64) arr Out[3]: array([[1, 2, 3], [4, 5, 6]], dtype=int64) Inspect general information of an array¶ In [4]: print(np.info(arr)) class: ndarray shape: (2, 3) strides: (24, 8) itemsize: 8 aligned: True contiguous: True …
Read More »Numpy Datatypes
3 – Numpy Data Types NumPy Data Types¶ In [2]: import numpy as np import pandas as pd Data Types in NumPy¶Numpy has the following data types: int float complex bool string unicode object The numeric data types have various precisions like 32-bit or 64-bit. Numpy data types can be represented …
Read More »Creating NumPy Array
2 – Create an Array Create a NumPy Array¶The learning objectives of this section are: Understand advantages of vectorised code using NumPy (over standard python ways) Create NumPy arrays Convert lists and tuples to NumPy arrays Create (initialise) arrays Compare computation times in NumPy and standard Python lists NumPy Basics¶NumPy …
Read More »Introduction to NumPy
1 – Introduction to Numpy Introduction to NumPy¶NumPy (numerical Python) is a library that consists of multidimensional array objects and a set of routines for processing them. NumPy allows you to perform mathematical and logical operations on arrays. This tutorial walks you through the fundamentals of NumPy, including its design …
Read More »Python MySQL Installation
1 Python MySQL Installation Python MySQL Database¶SQL stands for Structured Query Language and is a widely used programming language for managing relational databases. Python can be used in database applications. One of the most popular databases is MySQL. Python needs a MySQL driver to access the MySQL database. pip install …
Read More »Python MYSQL Create Database
2 Python MySQL Create Database Python MySQL Create Database¶To create a database in MySQL, use the “CREATE DATABASE” statement: Note: In MySQL, it’s mandatory to put a semicolon (;) at the end of a statement, which denotes the termination of a query. However, MySQL Connector/Python automatically appends a semicolon at …
Read More »
Machine Learning Tutorials, Courses and Certifications