0

I am doing the basic tensorflow iris example and I came across the following well commented statement:

# 1. Assign the DataFrame's labels (the right-most column) to train_label.
# 2. Delete (pop) the labels from the DataFrame.
# 3. Assign the remainder of the DataFrame to train_features
train_features, train_label = train, train.pop(label_name)

My understanding: this is equivalent to:

train_features = train
train_label = train.pop(label_name)

My question: when we assign DataFrame train to train_features in the first statement, then in the second statement we pop the label_name, does that remove label_name from train_features?

Blank
  • 423
  • 1
  • 5
  • 16
  • Yes, an assignment doesn't make a copy, so all changes made to `train` are also reflected by `train_features`. – Aran-Fey Feb 04 '18 at 18:20
  • In Python's [documentation](https://docs.python.org/3/reference/expressions.html#evaluation-order) these expressions will be evaluated in the arithmetic order of their suffixes: `expr3, expr4 = expr1, expr2` it makes sense now. – Blank Feb 04 '18 at 18:31
  • That has nothing to do with it. The order doesn't make a difference here. – Aran-Fey Feb 04 '18 at 18:33
  • thanks! I didn't know that python used 'references'. Indeed you are right, that order doesn't really affect the variables in this case. I need to get used to this notion. – Blank Feb 04 '18 at 19:23

0 Answers0