polars icon indicating copy to clipboard operation
polars copied to clipboard

fix(rust): fix specified column order for read_csv

Open romanovacca opened this issue 1 year ago • 0 comments

fix #13066

in fn parse_csv(), we use get_projection(), which uses the projection that contains the correct columns and order. That function mentions: we also need to sort the projection to have predictable output, which happens via sort_unstable(), which leads to a different order of the projection/columns.

In my fix, we now take the original projection and use that to fetch the matching column names, and when all the chunks of data are processed, I reorder the dataframe (if column_names was specified), into the order that was initially passed.

I would expect this reordering to be present somewhere already, but I couldn't find it

romanovacca avatar Dec 24 '23 15:12 romanovacca