Community Conundrum 28: News Engagement is live! Read More

Sorting in Analyze

Sorting in Analyze
How can I sort a dataset in the Analyze section over a column?
3 Replies
Hi Simon,

This is not possible to sort a dataset in an Analyze section or a visual preparation recipe. It might me available in a future release.
However, you can sort a dataset with a Python/R/SQL recipe.
Jeremy, Product Manager at Dataiku
0 Kudos
Level 1

  • In your Dataset choose Actions > Python > Recipee

  • Add a new Output Dataset in  the modal window

  • Copy and adapt the following code snippet

# -*- coding: utf-8 -*-
import dataiku
import pandas as pd, numpy as np
from dataiku import pandasutils as pdu

# Input datasets
input_dataset = dataiku.Dataset("Input_dataset")
input_dataset_df = input_dataset.get_dataframe()
sorted_dataset = input_dataset_df.sort(["column_i_want_to_sort"], ascending=[0])

# Output datasets
output_dataset = dataiku.Dataset("Output_dataset")

  • Run the script, boom your column is sorted \o/


Starting with DSS 4.0 you can sort values of your sample in the preview. Click on the header of a column and select sort.

Note that if you want to write out a sorted dataset, the selected answer is still the way to go.
0 Kudos
Labels (1)
A banner prompting to get Dataiku DSS