Updating a variable from a dataset

Level 1
Updating a variable from a dataset

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 = df_data['Year']



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

Operating system used: Mac OS

0 Kudos
1 Reply

Hi @akember182,

If you want to set a global variable, you'll need to use the set_global_variables method: https://developer.dataiku.com/latest/api-reference/python/scenarios-inside.html#dataiku.scenario.Sce...

Please try the following:



Please let us know if you have any questions.



0 Kudos