0
$\begingroup$

My numpy array has the shape of (99,2) basically it has 2 columns one is the word and the other is a hot encoding vector size of 300 I want to delete the column of words and want to have only encoding vectors

in order to delete I have to use the simple line of code

arr = np.delete(x, 0, axis=1)

it deletes the all words but gives me the shape of

(99,1)

How Can I have the shape of (99,300)

$\endgroup$
2
  • $\begingroup$ That depends on the format of the data in your array. Could you provide details on what one element of your data looks like? $\endgroup$ Jan 27, 2023 at 11:24
  • $\begingroup$ Thank you for the reply , $\endgroup$ Jan 27, 2023 at 13:34

1 Answer 1

1
$\begingroup$

The trick I used is as below

First del that column by the following command

arr = np.delete(x, 0, axis=1)

Second Flatten the array ad make it a list

flt= arr.flatten()
flt =list(flt)

last make the new numpy array to restore the dimensions

new_arr = np.array(flt)

it gives me the desired shape

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.