81-126のようなオブジェクトを含む、フィールド/列'observation_id'を持つアストロピー テーブルinput_tableがあります。2 つの数値 (81 と 126) を分離し、整数として保存したいと考えています。各ステップで持っているオブジェクトのタイプを示すために、ここにすべてのステップを書いています。不明な点がありましたらお知らせください。
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'>
次のようにして文字列を整数に変換すると、
In [70]: int(float(nx))
私は得る:
---------------------------------------------------------------------------
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'
文字列 '8\x00\x00\x001\x00\x00\x00' のタイプのリンクを見る
私は試した
In [71]: nx,ny=str.decode(encode='utf-16-le').split('-')
しかし、私は得る
---------------------------------------------------------------------------
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'
さらに進む方法がわかりません。誰か助けてくれませんか?