Python Forum
Dictionary or Numpy Array? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Dictionary or Numpy Array? (/thread-13241.html)



Dictionary or Numpy Array? - jarrod0987 - Oct-05-2018

First, can someone please show the proper code for creating a 5 row 2 column numpy array with type python object?
I see a lot of info online but none of it seems to quite show how to do that in one example.

Second,
If I want to have a string for a key and a number for a value, is Dictionary faster or is it really worth it to to build a numpy array? There will be over 450 000 keys btw. I'm doing quadragrams.

Thanks


RE: Dictionary or Numpy Array? - ichabod801 - Oct-05-2018

I think this Stack Overflow question has what you want.

I would use a dictionary. I believe the numpy array is meant to optimize certain list operations, not dictionary operations.


RE: Dictionary or Numpy Array? - jarrod0987 - Oct-05-2018

Seems to be what I wanted. Thanks