From a98f857a5de11863bee1acb65b7d31180270789e Mon Sep 17 00:00:00 2001 From: Sylvain Lesage Date: Tue, 15 Feb 2022 18:41:52 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20preserve=20order=20of=20t?= =?UTF-8?q?he=20columns=20when=20infered=20from=20the=20rows=20(#146)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- src/datasets_preview_backend/models/column/__init__.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5c10d2a204..a51ea5fbc5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ authors = ["Sylvain Lesage "] description = "API to extract rows of 🤗 datasets" name = "datasets-preview-backend" -version = "0.16.18" +version = "0.16.19" [tool.poetry.dependencies] Pillow = "^8.4.0" diff --git a/src/datasets_preview_backend/models/column/__init__.py b/src/datasets_preview_backend/models/column/__init__.py index f0f610da04..5e62c7dca8 100644 --- a/src/datasets_preview_backend/models/column/__init__.py +++ b/src/datasets_preview_backend/models/column/__init__.py @@ -75,7 +75,9 @@ def get_columns(info: Info, rows: List[Row]) -> List[Column]: return [] else: column_names = list( - {column_name for row in rows[:MAX_ROWS_FOR_TYPE_INFERENCE_AND_CHECK] for column_name in row.keys()} + dict.fromkeys( + column_name for row in rows[:MAX_ROWS_FOR_TYPE_INFERENCE_AND_CHECK] for column_name in row.keys() + ) ) else: column_names = list(features.keys())