python - Is there a way to speed up the pandas getitem, getitem_axis and get_label? -


i have loop below , can't use assign or vectorize because modifying several objects , functions further down line. however, pandas selections taking bulk of execution time. there way circumvent this?

if date in data[instrument].index:        row = data[instrument].ix[date]  
  • nb calls tottime percall cumtime
  • 34124 0.04444 1.302e-06 7.085 0.0002076 indexing.py:108(_getitem)

  • 34124 0.08395 2.46e-06 7.029 0.000206 indexing.py:1044(_getitem_axis)

  • 34124 0.0316 9.26e-07 6.242 0.0001829 indexing.py:123(_get_label)
  • 34124 0.258 7.56e-06 6.207 0.0001819 generic.py:1827(xs)

edit: turns out dict.__getitem__ faster above methods pandas. therefore, can convert this:

dict[(date, instrument)] = pd.series.to_dict(data[instrument].ix[date]).  

i need set once , rest of code reuse several times around 54 times faster.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -