What's the best way to change (convert) column type in Dataset

I’m struggling to convert the integer column to float one. I didn’t find anything related to HF datasets documentation.

Looks like the best way to deal with this is to use cast method.

Yes indeed ! :slight_smile:
for example

from datasets import * 

d = Dataset.from_dict({"a": [1, 2, 3]})

d2 = d.cast(Features({"a": Value("float32")}))
print(d2.features)
# {'a': Value(dtype='float32', id=None)}
1 Like