Search code examples
azureazure-machine-learning-service

Replace values in a column based on a condition in Azure ML Studio


How do I replace the values in a specific column with a particular value based on a condition in Azure ML Studio. I can do this using pandas in python as foolows:

df.loc[df['col_name'] > 1990, 'col_name'] = 1

I'm trying to find a Module in Azure Machine Learning Studio that does the equivalent of this.

I understand there is a replace option under the ConverToDataset module and a Replace Discrete Values module. But neither of these seems to do what I want. Is there an option to replace the values in just one column to a specific value based on a condition?


Solution

  • You can use either the more general Apply SQL Transformation, or the dedicated Clip Values module. If all else fails, there's also Execute Python Script.

    Personally, for your example I'd use Clip Values with Clip Peaks and Upper Threshold set. For more complex rules I'd use either Apply SQL Transformation or Execute Python Script, depending on the rules but favouring SQL :).