Skip to content
Advertisement

Tag: pass-by-reference

Change pandas dataframe content in a function

I’m writing a class that does one hot encoding, but it doesn’t work as I expected. On my main code I have this: The class method is the following: Now, with print(data.columns) I can see that the method works correctly, but when train_x_categorical.head() runs I can’t see the effect of the method applyOneHotEncoding. I don’t understand why this is happening

How do I pass a variable by reference?

Are parameters passed by reference or by value? How do I pass by reference so that the code below outputs ‘Changed’ instead of ‘Original’? See also: Why can a function modify some arguments as perceived by the caller, but not others? Answer Arguments are passed by assignment. The rationale behind this is twofold: the parameter passed in is actually a

Advertisement