Wei-Meng Lee
Mar 13, 2023

--

I would use a join:

import polars as pl

df_sex = pl.LazyFrame(

{

'Sex':['female','male'],

'Sex_Value':[0,1]

}

)

q = (

pl.scan_csv('Titanic_train.csv')

.join(

df_sex, on='Sex', how='inner'

)

.select(

pl.exclude('Sex')

)

)

q.collect()

--

--

Wei-Meng Lee
Wei-Meng Lee

Written by Wei-Meng Lee

ACLP Certified Trainer | Blockchain, Smart Contract, Data Analytics, Machine Learning, Deep Learning, and all things tech (http://calendar.learn2develop.net).

No responses yet