2

When trying to make a variable zip, i found out that the variable way doesnt achieve the same as the fixed way. When I look to the strings they are the same and the type of variable is the same, but the methods are still different.

element=State_4
inputZIP1='entrenamiento.'+element
inputZIP2='entrenamiento.'+element+'_ENCODED'

mydict=dict(zip(entrenamiento.State_4,entrenamiento.State_4_ENCODED))
mydict2=dict(zip(inputZIP1,inputZIP2))

P.D. if anyone needs the full code to test it i can give it.

Carlos Mougan
  • 761
  • 1
  • 8
  • 21
  • We don't want the full code, we need a [mcve] with the _least_ amount of code that can be copy-pasted to reproduce the problem. Right now, I can't see what the problem is, and I can't see any errors that this code may have produced. Not sure why this has 4 upvotes. – cs95 Dec 31 '18 at 10:22
  • 3
    Without further explanation, I'm going to go out on a limb and assume you thought that you could access the variables by strings (spoiler alert: use a dictionary). – cs95 Dec 31 '18 at 10:24
  • 1
    `entrenamiento.State_4 != 'entrenamiento.State_4'`, the former is a `str` object, the latter can be any object (including strings), but it is accessing the `State_4` attribute of the object referenced by `entrenamiento` – juanpa.arrivillaga Dec 31 '18 at 10:25

0 Answers0