From a43eb5513c40a452eae0a386085bcc6a37886dfd Mon Sep 17 00:00:00 2001 From: Luis Arias Date: Tue, 14 May 2024 10:10:08 +0200 Subject: [PATCH] Optimize data sort order --- observable/src/data/films.sqlite.py | 3 +++ observable/src/data/series.sqlite.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/observable/src/data/films.sqlite.py b/observable/src/data/films.sqlite.py index 21d6286..31895f1 100755 --- a/observable/src/data/films.sqlite.py +++ b/observable/src/data/films.sqlite.py @@ -70,6 +70,9 @@ # Set original title to blank string if same as title df["original_title"] = df["original_title"].where(df["title"] != df["original_title"], "") +# Sort dataframe by 'popularity' in descending order +df = df.sort_values(by="popularity", ascending=False) + # Save the dataframe to a SQLite database with tempfile.NamedTemporaryFile(suffix=".sqlite", delete=False) as temp_file: temp_filename = temp_file.name diff --git a/observable/src/data/series.sqlite.py b/observable/src/data/series.sqlite.py index 344b40b..9132ef0 100755 --- a/observable/src/data/series.sqlite.py +++ b/observable/src/data/series.sqlite.py @@ -35,6 +35,9 @@ "", ) +# Sort dataframe by 'popularity' in descending order +df = df.sort_values(by="popularity", ascending=False) + # Save the dataframe to a SQLite database with tempfile.NamedTemporaryFile(suffix=".sqlite", delete=False) as temp_file: temp_filename = temp_file.name