From 4aa70d0f43fcf919670995a3acf348c109b52a25 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Mon, 11 Jan 2016 15:15:11 -0800 Subject: [PATCH] Ordering columns in the Druid pandas df --- TODO.md | 1 - panoramix/models.py | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index a4f5215135..597753d770 100644 --- a/TODO.md +++ b/TODO.md @@ -4,7 +4,6 @@ List of TODO items for Panoramix ## Features * **URL shortner** * **Dashboard URL filters:** `{dash_url}#fltin__fieldname__value1,value2` -* **Browser history in explore.html:** use location.hash to manage query history * **Default slice:** choose a default slice for the dataset instead of default endpoint * **refresh freq**: specifying the refresh frequency of a dashboard and specific slices within it, some randomization would be nice * **Color hash in JS:** it'd be nice to use the same hash function for color attribution of series diff --git a/panoramix/models.py b/panoramix/models.py index b8d5423515..76a6ae533b 100644 --- a/panoramix/models.py +++ b/panoramix/models.py @@ -916,6 +916,15 @@ class Datasource(Model, AuditMixinNullable, Queryable): client.groupby(**qry) query_str += json.dumps(client.query_dict, indent=2) df = client.export_pandas() + + # Reordering columns + cols = [] + if 'timestamp' in df.columns: + cols += ['timestamp'] + cols += [col for col in groupby if col in df.columns] + cols += [col for col in metrics if col in df.columns] + cols += [col for col in df.columns if col in cols] + df = df[cols] return QueryResult( df=df, query=query_str,