0

I was trying to upload my dataset to python by following this discussion. Yet my code gives error. You can see the code and the error in image. Can you guys help me to fix it?

Code&error

5
  • why don't you just try pref_mat['a']? Commented Sep 24, 2020 at 23:41
  • 1
    I am kinda new to python so just tried to apply what i read. Apart from that your suggestion worked just fine. Thank you Commented Sep 24, 2020 at 23:46
  • Okay. Great. I have also added an answer. It would be nice if you could accept and upvote that so that others can be see it as well. That's just a tradition in stackoverflow. Commented Sep 24, 2020 at 23:49
  • 1
    I was trying find a way to turn question status to solved but only after refreshing the page i saw your answer (i didn't know that i can't point a comment as an answer so was trying to figure out how can i turn it to answer). Sorry for delay Commented Sep 24, 2020 at 23:52
  • No problem. Good luck and Happy Coding !! Commented Sep 24, 2020 at 23:54

1 Answer 1

0

Just use pref_mat['a']. Here is an example reproducing the error:

>>>from scipy.io import loadmat
>>> pref_mat = loadmat('global.mat')
>>>_['global_']

TypeError: string indices must be integers

>>> pref_mat['global_']
array([[1, 3, 5]], dtype=uint8)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.