3

I have a script that keep messing up and I am not sure what the source is. It seems to work sometimes and not others. Here is an example.

In [29]: pricesEquities=financialMarketPrices['equities'].dropna(axis[0,1],how='all'))

In [30]: pricesEquities.head()
Out[30]: 
               aud      cad     chf      eur     gbp      inr     jpy     sek  \
date                                                                            
2003-01-01  3007.1  6614.54  4630.8  2386.41  3940.4  1100.15  843.29  493.20   
2003-01-02  3027.6  6740.05  4630.8  2522.24  4009.5  1093.05  843.29  514.79   
2003-01-03  3055.5  6772.66  4899.5  2502.19  4004.9  1089.60  843.29  519.75   
2003-01-06  3075.4  6837.27  4916.2  2529.86  4001.4  1084.35  860.07  519.75   
2003-01-07  3074.5  6802.78  4887.0  2504.91  3957.4  1081.80  853.93  518.66   

               usd  
date                
2003-01-01  879.82  
2003-01-02  909.03  
2003-01-03  908.59  
2003-01-06  929.01  
2003-01-07  922.93  

In [31]: returnsEquities = pricesEquities.pct_change().iloc[1:]

In [32]: returnsEquities.head()
Out [32]:    aud     cad  chf     eur  gbp     inr  jpy     sek    usd
date                                                                 
2003-01-02   -1  414.00  NaN  189.23  NaN  145.11  NaN  210.13    NaN
2003-01-03  NaN     NaN  NaN     NaN    0     NaN  NaN  217.26    NaN
2003-01-06  NaN     NaN  NaN     NaN    0     NaN    0     NaN  65.33
2003-01-07  NaN  436.00  NaN  191.79    0  146.50    0     NaN  60.63
2003-01-08  NaN  452.67  NaN  188.93    0  147.43    0  214.14  59.13

This is very strange and I honestly have no idea what the source of error might be. The percent change function seems to be the source of it and it works sometimes and not others seemingly at random. Has anyone else dealt with something like this before? Is there anything under the hood or unstable about my code? It also messes up elsewhere in the code, but this is the most simple of returns calculations and it still messes up. Does anyone have any idea what is going on?

4
  • That's strange, I think you can try to re-install the pandas package first.
    – cncggvg
    Mar 29, 2016 at 13:56
  • my .diff() function is malfunctioning as well. Going to try this to see if it works. Mar 29, 2016 at 14:59
  • updating pandas didnt work :/ have no idea. something with the code/script itself because getting same errors on my colleagues' computers as well. Malfunctions seemingly at random Mar 29, 2016 at 15:49
  • 1
    Random malfunctions are usually the result of numexpr 2.4.4 being installed, which is very flaky. Updating the installation probably upgraded numexpr to >= 2.4.6, and those versions work.
    – DSM
    Mar 30, 2016 at 22:27

2 Answers 2

3

I confirm the problem. I was having issues with pct_change, saw this and checked my version of numexpr and found it to be 2.4.4.

In fairness to the developers of pandas and numexpr, I think I may have tried to upgrade pandas via pip instead of through conda and perhaps this caused the issues.

To fix the problem, I think did the following on windows:

/path/to/Anaconda/Scripts/conda.exe update conda
/path/to/Anaconda/Scripts/conda.exe update anaconda

After that things seemed to work correctly.

0

problem solved: we were using continuum anaconda and we believe the install was wrong. we reinstalled and now everything seems to be working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.