Discover this year's submissions to the Dataiku Frontrunner Awards and give kudos to your favorite use cases and success stories!READ MORE

Sorting in Analyze

Solved!
UserBird
Dataiker
Dataiker
Sorting in Analyze
How can I sort a dataset in the Analyze section over a column?
1 Solution
abanctelchevrel
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/



 

View solution in original post

3 Replies
jereze
Dataiker Alumni
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
abanctelchevrel
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/



 

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

?
Labels (1)
A banner prompting to get Dataiku