top of page

DATA SCIENCE

Numpy : ​

  • NumPy is a fundamental Python library used for scientific and numerical computing.

  • Its name stands for Numerical Python, and it is the core library for working with arrays, which are like advanced lists that allow you to perform mathematical operations efficiently.

  • Multidimensional array object, and has functions and tools for working with these arrays.

 

  • ​pip install numpy

Import NumPy

Why Use NumPy?

  1. Fast Calculations: It enables fast operations on large arrays and matrices because it is implemented in C and optimized for performance.

  2. Multidimensional Arrays: You can create arrays of any dimension (1D, 2D, 3D, etc.), making it easier to work with data like tables (matrices) or even higher-dimensional data.

  3. Mathematical Operations: It offers a range of operations like addition, subtraction, and multiplication that work element-wise on arrays.

  4. Used in Data Science: NumPy is the base for many other libraries like Pandas, SciPy, and frameworks like TensorFlow.

Basic Concepts

1. ndarray (N-dimensional Array)

NumPy is an N-dimensional array type called ndarray.

Top Data Science Training Center in Coimbatore

Example: Create a One-dimensional Array

import numpy

a = numpy.array([1, 2, 3, 4, 5])

print(a)

Output:

[1 2 3 4 5]

Example: Create a Multi-dimensional Array

import numpy as np 

arr_2d = np.array([[1, 2, 3], [4, 5, 6]])

print(arr_2d)

Output:

[[1 2 3]

[4 5 6]]

2. Array Operations

import numpy as np

arr1 = np.array([1, 2, 3])

arr2 = np.array([4, 5, 6]) # Element-wise addition

result = arr1 + arr2

print(result)

Output:

[5 7 9]

3. Shape and Size of an Array

arr = np.array([[1, 2, 3], [4, 5, 6]])

# Get shape (rows, columns)

print(arr.shape)

# Get the total number of elements

print(arr.size)

(2, 3)             # 2 rows and 3 columns

6                   # Total number of elements

Output:

4. Reshaping Arrays

arr = np.array([1, 2, 3, 4, 5, 6])

# Reshape to 2 rows and 3 columns

reshaped = arr.reshape(2, 3)

print(reshaped)

Output:

[[1 2 3]

[4 5 6]]

🌍 Join the Future of Tech!

Get in touch: admin@skyparkitech.com

Job Enquiry : hr@skyparkitech.com

© 2025 SKYPARK INSTITUTE OF TECHNOLOGY. All rights reserved.

Get in Touch

V V Complex ,

Hope College Bus stop,

Coimbatore - 641 004

  • Gmail
  • Telegram
  • Facebook
  • Youtube
  • Instagram
  • Whatsapp

91-599-78777 

91-599-68777

bottom of page