Is there a way to convert pandas dataframe to vectors? For example,
df
Out[53]:
Col1
3 Place
4 Country
Expected output
df_converted = 'Place','Country'
You can use method values
on a series. This returns a numpy array.
import pandas as pd
df = pd.DataFrame({
'Col1': ['Place', 'Country'],
'Col2': ['This', 'That'],
})
vector = df['Col1'].values
print(vector)
print(type(vector))
Output
['Place' 'Country']
<class 'numpy.ndarray'>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments