I have an astropy Table input_table with a field/column 'observation_id', which contains the objects like 81-126. I wish to separate the two numbers (81 and 126) and save them as integers. I am writing all the steps here to show the type of objects I have at each step. Please let me know if something is 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 I do the following to convert the string into 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: could not convert string to float: '8\x00\x00\x001\x00\x00\x00'
Looking at the link for the type of string '8\x00\x00\x001\x00\x00\x00'
I tried
In [71]: nx,ny=str.decode(encode='utf-16-le').split('-')
But I get
---------------------------------------------------------------------------
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 to proceed further. Could someone help please?