In [15]:
import os,sys
import numpy as np
import pandas as pd
import scipy.stats as stats
from collections import defaultdict
In [8]:
%%timeit
np.random.normal(size=1)
In [9]:
%%timeit
stats.norm().rvs()
In [26]:
ddf = {'a': pd.DataFrame({'a':range(10), 'b':range(10)}),
'b': pd.DataFrame({'a':range(10), 'b':range(10)})
}
narr = np.array([np.array(range(10) + range(10)).reshape(2,10).transpose(),
np.array(range(10) + range(10)).reshape(2,10).transpose()
])
In [27]:
ddf
Out[27]:
In [28]:
narr
Out[28]:
In [29]:
x = np.array([(1.0, 2), (3.0, 4)], dtype=[('x', float), ('y', int)])
In [42]:
y = pd.DataFrame({'x' : (1.0, 2), 'y' : (3.0, 4) })
In [45]:
%%timeit
x['x'][0] += 1
In [50]:
%%timeit
y['x'][0] += 1
In [53]:
a = np.zeros((10,10,10))
b = np.zeros((10*10*10,))
In [60]:
%%timeit
a[0,0,0] += 1
In [62]:
%%timeit
b[100] += 1
In [86]:
a = np.array([np.zeros((10,10)),np.zeros((10,10))])
b = {'a':np.zeros((10,10)), 'b':np.zeros((10,10))}
In [95]:
%%timeit
a[0,0,0] += 1
In [96]:
%%timeit
b['a'][0,0] += 1
In [110]:
a = np.random.uniform(size=100).reshape(10,10)
b = defaultdict(dict)
for x in range(a.shape[0]):
for y in range(a.shape[1]):
b[str(x)][str(y)] = a[x,y]
In [113]:
%%timeit
a[0,0] += 1
In [114]:
%%timeit
b['0']['0'] += 1
In [115]:
%%timeit
[x**2 for x in range(100)]
In [118]:
%%timeit
l = []
for x in range(100):
l.append(x**2)
In [ ]: