Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hello,
I want to take a dataset in input data, to add rows to this dataset and during the future execution of the scenario, to take in input the dataset with the rows previously added (like a loop).
What would be the best way to proceed?
Thanks in advance,
Hey @scholaschl ,
So you want to append one row with each scenario run to an existing dataframe. Is that about right?
There are two ways to solve this in my experience:
import dataiku
import numpy as np
dt = dataiku.Dataset('dataset_name')
df = dt.get_dataframe()
#required computation
new_arr = np.array(['col1_value', 'col2_value', 'col3_value']) #assuming it has 3 columns
#finding the last row and appending after that in the existing dataframe
df.loc([len(df)]) = new_arr
dt.write_dataframe(df)
Hope it helps!
Regards,
Madhuleena
Hey @scholaschl ,
So you want to append one row with each scenario run to an existing dataframe. Is that about right?
There are two ways to solve this in my experience:
import dataiku
import numpy as np
dt = dataiku.Dataset('dataset_name')
df = dt.get_dataframe()
#required computation
new_arr = np.array(['col1_value', 'col2_value', 'col3_value']) #assuming it has 3 columns
#finding the last row and appending after that in the existing dataframe
df.loc([len(df)]) = new_arr
dt.write_dataframe(df)
Hope it helps!
Regards,
Madhuleena
Thank you for your answer! It will help me.