Chr*_*rry 10 python numpy dataframe pandas
我正在从Pandas数据帧中隔离一些行ID,如下所示:
data = df.loc[df.cell == id]
rows = df.index
print(type(rows))
< class 'pandas.indexes.numeric.Int64Index'>
Run Code Online (Sandbox Code Playgroud)
我想将行转换为numpy数组,以便我可以使用sio.savemat将其保存到mat文件中.这会返回一个错误:
row_mat = rows.as_matrix()
AttributeError: 'Int64Index' object has no attribute 'as_matrix'
Run Code Online (Sandbox Code Playgroud)
请问有什么正确的方法?谢谢
use*_*344 26
试着rows = df.index.values改为