astype
NumPy で使用されるのと同じ方法で関数を使用して、DataFrame の型をキャストしようとしています。
最初の NumPy:
In [175]: x = np.rec.array([('a','1'),('b','2')],names='col1,col2')
In [176]: x
Out[176]:
rec.array([('a', '1'), ('b', '2')],
dtype=[('col1', '|S1'), ('col2', '|S1')])
In [177]: dt=[('col1', '|S1'), ('col2', 'i8')]
In [178]: x.astype(dt)
Out[178]:
rec.array([('a', 1), ('b', 2)],
dtype=[('col1', '|S1'), ('col2', '<i8')])
次にパンダで:
In [182]: y = DataFrame([('a','1'),('b','2')], columns=['col1','col2'])
In [183]: y
Out[183]:
col1 col2
0 a 1
1 b 2
In [184]: y.astype(dt)
Out[184]: ---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
...
NotImplementedError: Not implemented for this type
私は pandas 0.7.3 を使用しており、http://pandas.sourceforge.net/generated/pandas.DataFrame.astype.htmlにある pandas 0.7.0 のドキュメントから取得しています。どうしたの?