Python Forum

Full Version: Dictionary or Numpy Array?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.
Seems to be what I wanted. Thanks