in Technology by
Shown below is the input NumPy array. Delete column two and replace it with the new column given below.

1 Answer

0 votes
by

import NumPy

sampleArray = NumPy.array([[34,43,73],[82,22,12],[53,94,66]]) 

newColumn = NumPy.array([[10,10,10]])

Expected Output:

Printing Original array

[[34 43 73]

 [82 22 12]

 [53 94 66]]

Array after deleting column 2 on axis 1

[[34 73]

 [82 12]

 [53 66]]

Array after inserting column 2 on axis 1

[[34 10 73]

 [82 10 12]

 [53 10 66]]

Solution:

import NumPy

print(“Printing Original array”)

sampleArray = NumPy.array([[34,43,73],[82,22,12],[53,94,66]]) 

print (sampleArray)

print(“Array after deleting column 2 on axis 1”)

sampleArray = NumPy.delete(sampleArray , 1, axis = 1) 

print (sampleArray)

arr = NumPy.array([[10,10,10]])

print(“Array after inserting column 2 on axis 1”)

sampleArray = NumPy.insert(sampleArray , 1, arr, axis = 1) 

print (sampleArray)

Related questions

0 votes
    How can you identify the datatype of a given NumPy array?...
asked Apr 24, 2021 in Technology by JackTerrance
0 votes
    I have a dataframe as below itm Date Amount 67 420 2012-09-30 00:00:00 65211 68 421 2012-09-09 00 ... solutions would be appreciated. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I need to iterate through the elements in a numpy array so I can treat any zero elements separately. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I need to iterate through the elements in a numpy array so I can treat any zero elements separately. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I have a dataframe with which if a cell has a value other than "." then I need python to return ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    I have the dataset that has the no_employees column that is the str object. whats is a best way to create the new ... 1-5 |Very Small Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have Conversation classes with a members relation attribute pointing to User class. This members attribute consists ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I have a table in my android app with a column named tags, this column can contain one or ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    Match column I with column II and select the correct answer using the codes given below the columns. Column - I Political ... 2, D - 4 Select the correct answer from above options...
asked Aug 3, 2022 in Education by JackTerrance
0 votes
    Point out the wrong statement. (a) Each universal function takes array inputs and produces array outputs (b) Broadcasting ... input arguments are ndarrays (d) All of the mentioned...
asked Oct 7, 2021 in Technology by JackTerrance
0 votes
    What are the steps to use shape for a 1D array, 2D array and 3D/ND array respectively in NumPy?...
asked Apr 24, 2021 in Technology by JackTerrance
0 votes
0 votes
    What is the procedure to find the indices of an array on NumPy where some condition is true?...
asked Apr 24, 2021 in Technology by JackTerrance
0 votes
    How do you create a 3D array in NumPy?...
asked Apr 24, 2021 in Technology by JackTerrance
0 votes
    Determine the input impedance of the network shown below. (a) 4.25 (b) 3.25 (c) 2.25 (d) 1.25 ... theory Questions for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 13, 2021 in Education by JackTerrance
...