I have two tables -Source and Target,in Target I want to update values for one column randomly

pphanireddy007
Level 1
I have two tables -Source and Target,in Target I want to update values for one column randomly

 I have two tables -Source and Target,in Target I want to update values for one column randomly from source table

0 Kudos
1 Reply
AlexT
Dataiker

Hi @pphanireddy007 ,

You can use a code recipe in this case:

import dataiku
import pandas as pd, numpy as np
from dataiku import pandasutils as pdu

# Read recipe inputs
dataset_1 = dataiku.Dataset("airline_stocks_prepared")
df1 = dataset_1.get_dataframe()
dataset_2 = dataiku.Dataset("airline_stocks")
df2 = dataset_2.get_dataframe()


np.random.seed(123)  # for reproducibility
df2['random_value'] = np.random.choice(df1['column_name'], size=len(df2))


# Write recipe outputs
result = dataiku.Dataset("result")
result.write_with_schema(df2)
0 Kudos