Using the NumPy data structures and methods

The term NumPy is short for Numerical Python; the library name is numpy. The library provides arrays with much more efficient storage and faster work than basic lists and dictionaries. Unlike basic lists, numpy arrays must have elements of a single data type. The following code imports the numpy package with the alias np. Then it checks the version of the library. Then the code creates two one-dimensional arrays from two lists, one with an implicit element data type integer, and one with an explicit float data type:

import numpy as np 
np.__version__ 
np.array([1, 2, 3, 4]) 
np.array([1, 2, 3, 4], dtype = "float32") 

You can create multi-dimensional arrays as well. The following code creates three ...

Get SQL Server 2017 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.