From 9cfeae33fdaf40150e6fbf1f4150a122a3ad3f56 Mon Sep 17 00:00:00 2001 From: romanovacca Date: Sun, 24 Dec 2023 16:16:52 +0100 Subject: [PATCH] added test --- py-polars/tests/unit/io/test_csv.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/py-polars/tests/unit/io/test_csv.py b/py-polars/tests/unit/io/test_csv.py index 463e3b1364a0..522b1e8c639b 100644 --- a/py-polars/tests/unit/io/test_csv.py +++ b/py-polars/tests/unit/io/test_csv.py @@ -372,7 +372,7 @@ def test_dtype_overwrite_with_column_name_selection() -> None: ) f = io.StringIO(csv) df = pl.read_csv(f, columns=["c", "b", "d"], dtypes=[pl.Int32, pl.String]) - assert df.dtypes == [pl.String, pl.Int32, pl.Int64] + assert df.dtypes == [pl.Int32, pl.String, pl.Int64] def test_dtype_overwrite_with_column_idx_selection() -> None: @@ -387,9 +387,16 @@ def test_dtype_overwrite_with_column_idx_selection() -> None: df = pl.read_csv(f, columns=[2, 1, 3], dtypes=[pl.Int32, pl.String]) # Columns without an explicit dtype set will get pl.String if dtypes is a list # if the column selection is done with column indices instead of column names. - assert df.dtypes == [pl.String, pl.Int32, pl.String] + assert df.dtypes == [pl.Int32, pl.String, pl.String] # Projections are sorted. - assert df.columns == ["b", "c", "d"] + assert df.columns == ["c", "b", "d"] + + +def test_column_order_column_names_specified() -> None: + csv = "a,b,c\n" "1,2,3\n" "1,2,3\n" + f = io.StringIO(csv) + df = pl.read_csv(f, columns=["b", "a", "c"]) + assert df.columns == ["b", "a", "c"] def test_partial_column_rename() -> None: