I am isolating some row ids from a Pandas dataframe, like this:
data = df.loc[df.cell == id]
rows = df.index
print(type(rows))
< class 'pandas.indexes.numeric.Int64Index'>
I want to convert rows to a numpy array so I can save it to a mat file using sio.savemat. This is returning an error though:
row_mat = rows.as_matrix()
AttributeError: 'Int64Index' object has no attribute 'as_matrix'
What is the correct way, please? Thanks
try rows = df.index.values
instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With