Sorting in Analyze

UserBird Dataiker, Alpha Tester Posts: 535 Dataiker
How can I sort a dataset in the Analyze section over a column?

Best Answer

  • abanctelchevrel
    abanctelchevrel Registered Posts: 1 ✭✭✭✭
    edited July 17 Answer ✓
    • 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/


  • jereze
    jereze Alpha Tester, Dataiker Alumni Posts: 190 ✭✭✭✭✭✭✭✭
    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.
  • cperdigou
    cperdigou Alpha Tester, Dataiker Alumni Posts: 115 ✭✭✭✭✭✭✭
    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.
Setup Info
      Help me…