vaexio / vaex

Out-of-Core hybrid Apache Arrow/NumPy DataFrame for Python, ML, visualization and exploration of big tabular data at a billion rows per second 🚀
https://vaex.io
MIT License
8.22k stars 590 forks source link

Fix: auto-cast to correct type when using vconstant #2288

Closed JovanVeljanoski closed 1 year ago

JovanVeljanoski commented 1 year ago

See discussion at https://github.com/vaexio/vaex/issues/2286 This is largely inspired by the proposal of @NickCrews in https://github.com/vaexio/vaex/issues/2286

Checklist:

NickCrews commented 1 year ago

Looks like the right idea to me, but looks like it fails the unit tests when you give it a values of [1, 2]

JovanVeljanoski commented 1 year ago

Yeah I overlooked that case, i will handle it in the next iteration :). Thanks!

JovanVeljanoski commented 1 year ago

It should be fine now.. i've extended your idea @NickCrews to also be applied to lists.. if that is ever is needed. For example:

import vaex

length = 3
df = vaex.from_arrays(x=[1, 2, 3])
df['list_floats'] = vaex.vconstant(value=[1, 2, 3], length=length, dtype='float')
df['list_ints'] = vaex.vconstant(value=[1, 2, 3], length=length, dtype='int')
df['list_strings'] = vaex.vconstant(value=[1, 2, 3], length=length, dtype='str')

would do the equivalent thing, but now within the lists!