ankara escort
malatya escort
NumPy Exercises

NumPy: Access an array by column

NumPy: Array Object Exercise-81 with Solution

Write a NumPy program to access an array by column.

Sample Solution:-

Python Code:

import numpy as np
x= np.arange(6).reshape(3, 2)
print("Original array elements:")
print("Access an array by column:")
print("First column:")
print("Second column:")
print("Third column:")

Sample Output:

Original array elements:                                               
[[0 1]                                                                 
 [2 3]                                                                 
 [4 5]]                                                                
Access an array by column:                                             
First column:                                                          
[0 1]                                                                  
Second column:                                                         
[2 3]                                                                  
Third column:                                                          
[4 5]

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a NumPy program to convert a NumPy array into Python list structure.
Next: Write a NumPy program to convert a numpy array of float values to a numpy array of integer values.

What is the difficulty level of this exercise?

New Exercises:R Programming