Check out the first Dataiku 8 Deep Dive focusing on Productivity on October 29th Read More

Sorting in Analyze

Dataiker
Dataiker
Sorting in Analyze
How can I sort a dataset in the Analyze section over a column?
3 Replies
Dataiker
Dataiker
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")
output_dataset.write_with_schema(sorted_dataset)



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



 

Dataiker
Dataiker
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