How to delete a column in a numpy array with Python

1 Answer

0 votes
import numpy as np

def column_delete(arr, column_index):
   return np.delete(arr, column_index, axis=1)

numpy_array = np.array([['Python', 'C', 'C++'],
                        ['C#', 'Java', 'PHP'],
                        ['Go', 'Rust', 'Scala']])
               
new_array = column_delete(numpy_array, 1)

print("\nAfter Deletion \n",new_array)


  
'''
run:
  
 [['Python' 'C++']
 ['C#' 'PHP']
 ['Go' 'Scala']]
  
'''

 



answered Jan 21 by avibootz

Related questions

...