Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

3d array in numpy

>>> a = np.zeros((2, 3, 4))
>>> a
array([[[ 0.,  0.,  0.,  0.],
        [ 0.,  0.,  0.,  0.],
        [ 0.,  0.,  0.,  0.]],

       [[ 0.,  0.,  0.,  0.],
        [ 0.,  0.,  0.,  0.],
        [ 0.,  0.,  0.,  0.]]])
Comment

3d array numpy

# required libraries
import numpy as npy

array_3d = npy.array(
    [[[1, 1, 1, 1],
    [1, 1, 1, 1],
    [1, 1, 1, 1]],
    
    [[1, 1, 1, 1],
    [1, 1, 1, 1],
    [1, 1, 1, 1]]])

print(array_3d)
print("Number of dimensions: " ,array_3d.ndim, ", Shape: ", array_3d.shape)
# you can type the array yourself like this
# or you could do somethong like this

ones = npy.ones((2, 3, 4), dtype=int)
print(ones)
print("Number of dimensions: " ,ones.ndim, ", Shape: ", ones.shape)
# and get the same result
Comment

PREVIOUS NEXT
Code Example
Python :: case statement in pandas 
Python :: pytest check exception 
Python :: bot wait_for discord py 
Python :: pip install django 
Python :: python kill process by name 
Python :: How do I get the parent directory in Python? 
Python :: python randomize a dataframe pandas 
Python :: filter list of tuples python 
Python :: python datetime weekday 
Python :: get int64 column pandas 
Python :: python print utf-8 
Python :: how to add three conditions in np.where in pandas dataframe 
Python :: pyautogui color 
Python :: pyttsx3 female voice template 
Python :: pandas str is in list 
Python :: is flask open source 
Python :: erase % sign in row pandas 
Python :: isprime python 
Python :: python regex get all matches 
Python :: python currency sign 
Python :: dataframe get index name 
Python :: how to take input from user in python 
Python :: print column in 2d numpy array 
Python :: create a list of a certain length python 
Python :: append one row to pandas dataframe 
Python :: how to write to a netcdf file using xarray 
Python :: api in python 
Python :: what is kali 
Python :: python ordered dictionary 
Python :: pandas series quantile 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =