salwaen
salwaen

Reputation: 81

Convert a column in vaex dataframe from String to Float or int

I tried theis solution But it didn't really solve my problem

x = ['a', 'b', 'c', 'd', 'e', 'f']
y = np.array(['10', '20', '30', '40', '50', '60'])
z = np.array(['x', 'y', 'z', 'f', 'b', 's'])
df_vaex = vaex.from_arrays(x=x, y=y, z=z)

df_vaex.y = df_vaex.y.astype('float64')
print(df_vaex.dtypes) 

output

x    <class 'str'>
y    <class 'str'>
z    <class 'str'>
dtype: object


how can I convert columns of string to numeric? Thanks.

Upvotes: 4

Views: 3191

Answers (1)

salwaen
salwaen

Reputation: 81

I found the solution https://github.com/vaexio/vaex/issues/944

df_vaex['y'] = df_vaex.y.astype('float64')

Upvotes: 4

Related Questions