What is the primary data structure in Numpy used for storing and performing operations on numerical data?

Tensor
Series
DataFrame
ndarray

The correct answer is D. ndarray.

An ndarray (numerical array) is a multidimensional array of homogeneous data. It is the primary data structure in NumPy and is used for storing and performing operations on numerical data.

A tensor is a multi-dimensional array of data. It is similar to an ndarray, but it can have more than three dimensions. Tensors are often used in machine learning and deep learning applications.

A series is a one-dimensional array of data. It is similar to an ndarray, but it can only have one dimension. Series are often used in data analysis and statistical applications.

A DataFrame is a two-dimensional array of data. It is similar to an ndarray, but it can have two dimensions. DataFrames are often used in data analysis and statistical applications.

Here is an example of an ndarray:

“`

import numpy as np
x = np.array([[1, 2, 3], [4, 5, 6]])
x
array([[1, 2, 3],
[4, 5, 6]])
“`

Here is an example of a tensor:

“`

import numpy as np
x = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
x.shape
(3, 3)
“`

Here is an example of a series:

“`

import numpy as np
x = np.array([1, 2, 3])
x.shape
(3,)
“`

Here is an example of a DataFrame:

“`

import numpy as np
x = np.array([[1, 2, 3], [4, 5, 6]])
x.shape
(2, 3)
“`