Reputation: 976
I know numpy.array is much faster and cost much less memory than the python built-in list.
Is there something dict like but much faster ? I only need to store int
: int
or int
: float
data.
Upvotes: 2
Views: 1263
Reputation: 80396
I would take a look at series
from pandas. As you can see from the examples, it works well with np.arrays
:
import numpy as np
from pandas import *
randn = np.random.randn
In [309]: s = Series(randn(5), index=randn(5))
In [310]: s
Out[310]:
1.968290 0.132438
-0.307750 0.158168
0.288507 2.129288
1.002813 -0.247056
-0.450041 1.731273
In [311]: foo = np.array([0., 1.5, 1.])
In [312]: s = Series(foo)
In [313]: s
Out[313]:
0 0.0
1 1.5
2 1.0
Upvotes: 1