Home > front end >  How to remove a column in a 3d list
How to remove a column in a 3d list

Time:01-24

I have a dataframe that I would like to remove column 0 from my dataframe. For example below.

  df= np.array([[[100,1,2,4,5,6,8],
      [87,1,6,20,22,23,34],
      [99,1,12,13,34,45,46]],      
      [[64,1,10,14,29,32,33],
      [55,1,22,13,23,33,35],
      [66,1,6,7,8,9,10]],        
      [[77,1,2,3,5,6,8],
      [811,1,2,5,6,8,10], 
      [118,1,7,8,22,44,56]

I would like my reslut to like this

Result = ([[[1,2,4,5,6,8],
      [1,6,20,22,23,34],
      [1,12,13,34,45,46]],         
      [[1,10,14,29,32,33],
      [1,22,13,23,33,35],
      [1,6,7,8,9,10]],      
      [[1,2,3,5,6,8],
      [1,2,5,6,8,10], 
      [1,7,8,22,44,56]]]

CodePudding user response:

For instance, you can use slices (see doc):

a = np.array([[[100, 1,2,3,], [99, 4,5,6]]])
# shape (1, 2, 4)

a = a[:, :, 1:]  # or a[..., 1:]
array([[[1, 2, 3],
        [4, 5, 6]]])

CodePudding user response:

using following code:

df_1 = np.delete(df, obj = 0, axis = 2)
  • Related