1
NumPy에서 사용되는 것과 동일한 방식으로 astype
함수를 사용하여 DataFrame 유형을 형 변환하려고합니다. NumPy와 최초pandas 데이터 프레임 유형 캐스트
: 팬더의 다음
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')])
: 나는 팬더 0.7.3을 사용하고 http://pandas.sourceforge.net/generated/pandas.DataFrame.astype.html에서 팬더 0.7.0에 대한 설명서에서있어
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
. 뭐가 문제 야?
DataFrame의 열 유형을 변환하려는 경우 열 단위로 변환합니다. – capitrane