decode - Python Astropy: string to integer conversion -


i have astropy table input_table field/column 'observation_id', contains objects 81-126. wish separate 2 numbers (81 , 126) , save them integers. writing steps here show type of objects have @ each step. please let me know if not clear.

in [62]: id=input_table['observation_id']  in [63]: str=id[0]  in [64]: print(str) 81-126  in [65]: print(type(str)) <class 'numpy.str_'>  in [66]: nx,ny=str.split("-")  in [67]: print(nx,ny) 81 126  in [68]: print(type(nx),type(ny)) <class 'str'> <class 'str'> 

when following convert string integer,

in [70]: int(float(nx)) 

i get:

--------------------------------------------------------------------------- valueerror                                traceback (most recent call last) <ipython-input-70-7cfc33470a5c> in <module>() ----> 1 int(float(nx))  valueerror: not convert string float: '8\x00\x00\x001\x00\x00\x00' 

looking @ link type of string '8\x00\x00\x001\x00\x00\x00'

i tried

in [71]: nx,ny=str.decode(encode='utf-16-le').split('-') 

but

--------------------------------------------------------------------------- attributeerror                            traceback (most recent call last) <ipython-input-71-5f8d49af6ed1> in <module>() ----> 1 nx,ny=str.decode(encode='utf-16-le').split('-')  attributeerror: 'numpy.str_' object has no attribute 'decode' 

i don't know how proceed further. please?

i can't reproduce example in python 2.7 or 3.3 numpy 1.7. can give more specifics versions , platform?

one point using str variable overloads built-in str type. don't think directly problem here not idea in general.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -