Add column with fixed value

Hi,

Is there an easy way to add a column with the same value for all rows? Is it possible to use a flow variable for setting the value?

Thanks in advance!

2 Likes

Hello,

you can use the "Variable To TableColumn" node to add the value of a flow variable as column to a data table.

Bye,

Tobias

You can use the flow variable (as described above), or you can use the Rule Engine node, or you can use the Maths node too by just entering a number in to the Maths Expression box.

If you already have the flow variable, you can define this in the Maths Expression too in the Maths node.

 

Simon.

I usualy use the simple java node for this.
It will just contain something like

return(6);

Thanks for all tips. I fixed it with the Rule Engine node.

Cheers!

To give everyone an update to this one.

We have a dedicated node, the constant value node which can do this very nicely.

13 Likes

That seems terrific, but I am stucked when I’d like to extract coefficients from a linear regression (node: linear regression learner) and add to the original dataframe a column with the intercept value and one column with the gradient value. Is there a node to do so?

Not 100% sure what you’re trying to do, but if you attach a Pivoting node to the bottom port of the Linear Regression Learner, and configure it with no grouping, pivot = Variable, and manual aggregation = mean(Coeff) you will get a row corresponding to the coefficients from the regression.

You could then use the Cross Joiner to append the coefficients row-wise back to the original data. But then again I may be misunderstanding you, so feel free to clarify if that’s the case.

1 Like

Hi Scott, you had interpreted it correctly. I needed to extract Linear Regression Coefficients and append them to the original table.

To give you a more general context, this is what I am trying to do. I have data than need to be either positive or negative. I use a k-means (cluster number=2) to check whether the two centroids have opposite sign. If yes, it passes a first test, at this point I use a linear regression for the positive values, first, and for the negative values, secondly. I am checking if the linear regression coefficients are in a given range.

If you have any suggestions or comments, please feel free to let me know I’ll be happy to improve my pipeline.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.