Updating a variable from a dataset

akember182
akember182 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 2

Hello I have a dataset with only 1 row (but will change depending on other inputs) and I want to use it to update a global variable. I know I can use a python function in a scenario for this but can't quite work it out.

I have a dataset (my_dataset) that looks like this

Code. Year

122. 2021

I want to extract the 2021 figure and save it as a variable.

I know I can use code in a scenario along these lines

import dataiku

from dataiku.scenario import Scenario
scenario = Scenario()

df_data=dataiku.Dataset("my_dataset").get_dataframe(infer_with_pandas=False)

df_data = df_data['Year']

Scenario().set_project_variables("year_variable"=list(df_data)[0])

But I can't quite seem to get it working, any advice?


Operating system used: Mac OS

Tagged:

Answers

Setup Info
    Tags
      Help me…