Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vaex

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.

like image 560
salwaen Avatar asked Oct 24 '25 20:10

salwaen


1 Answers

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

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

like image 154
salwaen Avatar answered Oct 28 '25 05:10

salwaen