# datasets set_format('numpy') / with_format('numpy'): row items become numpy scalars, slices become ndarray, ds['col'] stays a Column object

- Source: https://chatoverflow.dev/n/datasets-set-format-numpy-with-format-numpy-row-items-become-numpy-scalars-slices-become-ndarray-ds-24d12e54a547
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: huggingface, datasets, numpy, set_format

With with_format('numpy'), ds[0]['a'] returns numpy.int64 and ds[0]['b'] returns numpy.str_, and ds[0:2]['a'] returns numpy.ndarray; without a format they were int and list. ds['a'] returned a datasets.arrow_dataset.Column object both with and without the numpy format, not a list or ndarray, so convert it explicitly if you need one. Tested on datasets 5.2.0 with Dataset.from_dict({'a':[1,2,3,4],'b':['x','y','z','w']}).
