Skip to main content
Active reading [<https://en.wikipedia.org/wiki/NumPy>]. <https://www.youtube.com/watch?v=1Dax90QyXgI&t=17m54s>
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

Below is a simple way to convert a dataframe column into numpya NumPy array.

df = pd.DataFrame(somedict)  ytrain = df['label'] ytrain_numpy = np.array([x for x in ytrain['label']]) 

ytrain_numpy isytrain_numpy is a numpyNumPy array.

I tried with to.numpy(), but it gave me the below error: TypeError: no supported conversion for types: (dtype('O'),) while doing Binary Relevance classfication using Linear SVC. to

TypeError: no supported conversion for types: (dtype('O'),)* while doing Binary Relevance classfication using Linear SVC.

to.numpy() was converting the dataFrame into numpya NumPy array, but the inner element's data type was a list because of which the above error was observed.

Below is a simple way to convert dataframe column into numpy array.

df = pd.DataFrame(somedict)  ytrain = df['label'] ytrain_numpy = np.array([x for x in ytrain['label']]) 

ytrain_numpy is a numpy array.

I tried with to.numpy() but it gave me the below error: TypeError: no supported conversion for types: (dtype('O'),) while doing Binary Relevance classfication using Linear SVC. to.numpy() was converting the dataFrame into numpy array but the inner element's data type was list because of which the above error was observed.

Below is a simple way to convert a dataframe column into a NumPy array.

df = pd.DataFrame(somedict) ytrain = df['label'] ytrain_numpy = np.array([x for x in ytrain['label']]) 

ytrain_numpy is a NumPy array.

I tried with to.numpy(), but it gave me the below error:

TypeError: no supported conversion for types: (dtype('O'),)* while doing Binary Relevance classfication using Linear SVC.

to.numpy() was converting the dataFrame into a NumPy array, but the inner element's data type was a list because of which the above error was observed.

Below is a simple way to convert dataframe column into numpy array.

df = pd.DataFrame(somedict) ytrain = df['label']

ytrain_numpy = np.array([x for x in ytrain['label']])

df = pd.DataFrame(somedict) ytrain = df['label'] ytrain_numpy = np.array([x for x in ytrain['label']]) 

ytrain_numpy is a numpy array.

I tried with to.numpy()to.numpy() but it gave me the below error: TypeError: no supported conversion for types: (dtype('O'),) while doing Binary Relevance classfication using Linear SVC. to.numpy() was converting the dataFrame into numpy array but the inner element's data type was list because of which the above error was observed.

Below is a simple way to convert dataframe column into numpy array.

df = pd.DataFrame(somedict) ytrain = df['label']

ytrain_numpy = np.array([x for x in ytrain['label']])

ytrain_numpy is a numpy array.

I tried with to.numpy() but it gave me the below error: TypeError: no supported conversion for types: (dtype('O'),) while doing Binary Relevance classfication using Linear SVC. to.numpy() was converting the dataFrame into numpy array but the inner element's data type was list because of which the above error was observed.

Below is a simple way to convert dataframe column into numpy array.

df = pd.DataFrame(somedict) ytrain = df['label'] ytrain_numpy = np.array([x for x in ytrain['label']]) 

ytrain_numpy is a numpy array.

I tried with to.numpy() but it gave me the below error: TypeError: no supported conversion for types: (dtype('O'),) while doing Binary Relevance classfication using Linear SVC. to.numpy() was converting the dataFrame into numpy array but the inner element's data type was list because of which the above error was observed.

Source Link

Below is a simple way to convert dataframe column into numpy array.

df = pd.DataFrame(somedict) ytrain = df['label']

ytrain_numpy = np.array([x for x in ytrain['label']])

ytrain_numpy is a numpy array.

I tried with to.numpy() but it gave me the below error: TypeError: no supported conversion for types: (dtype('O'),) while doing Binary Relevance classfication using Linear SVC. to.numpy() was converting the dataFrame into numpy array but the inner element's data type was list because of which the above error was observed.