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: sorting of an empty df returns an empty df with a warning #2290

Closed JovanVeljanoski closed 1 year ago

JovanVeljanoski commented 1 year ago

Addresses https://github.com/vaexio/vaex/issues/2287

@maartenbreddels I wrapped this up in try/expect block as to now check for length every time a df is sorted. If you think this should be done the other way around (i.e. first check length) then try to sort, lemme know!

Thanks to @NickCrews for bringing this up.

maartenbreddels commented 1 year ago

Yeah, if think we can simply do, if len(df) == 0: return df.copy() what do you think about that solution? This solution can accidentally do more .

JovanVeljanoski commented 1 year ago

yeah sounds good, i just didn't want to check length each time without needing to.. but if you think that is not too muc overhead (for heavily filtered dfs) I am happy, and the code will be cleaner

maartenbreddels commented 1 year ago

It might trigger a compute if the filter is not yet computed, but that will happen anyway for the sort.