Reputation: 285
This formula used to work for me. I tried to upgrade my Pandas version. It seems to work (although I got a boatload a strange message during the pip upgrade). But now I get a weird result from only this one type of operation.
postionVar = str(myDF[(myDF['TableFieldName']==myArray[innerLoop])].index)
I used to just get 0 now I get this instead:
"Int64Index([0], dtype='int64')"
This is literally what goes into my text string where I just need the index position value. So if 0 is the position of a value I don't get 0 anymore I get this: "Int64Index([0], dtype='int64')"
Upvotes: 1
Views: 377
Reputation: 393893
The following would work:
postionVar = str(myDF[myDF['TableFieldName']==myArray[innerLoop]].index[0])
This accesses the first element of the index object returned and so can now be cast to the string representation as you desire
Example:
In [222]:
df = pd.DataFrame({'a': arange(5)})
str(df[df['a'] == 3].index[0])
Out[222]:
'3'
Upvotes: 2