Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Pandas Version

What version of Pandas is Quantopian using? I tried to call .sort_values() on a Series and it says it doesn't exist.

8 responses

We're running pandas version 0.16.1

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Is there any chance we could get a version call added to the API that would return the versions of Python and Pandas? (It would be much speedier than asking here.)

So, about API functions that could return versions? I don't suppose they've been added in Q2?

This is easy to do with most Python libraries, for example:

import pandas as pd  
print pd.__version__  

I just ran this and it reports the version previously mentioned (0.16.1).

See: http://stackoverflow.com/questions/20612645/how-to-find-the-installed-pandas-version

Perfect! Exactly what I was looking for.

Do you know if it's possible to get the Python version in a similar way?

In research I tried

import IPython  
IPython.__version__

But we cannot import IPython

"I will use zipline to develop my code!", said B.
"That way I can use a real debugger and editor!", said B.
"I will be able to make more sophisticated algorithms!", said B.
And so B developed code with lots of math, using zipline, which by default imported the latest pandas 18.1.
Thousands of lines of code later, with a not-so-small amount of porting, he ran his code on Quantopian, and the Quantopian backtester said: "AttributeError: 'DataFrame' object has no attribute 'ewm'," "pd.__version__ 0.16.1."
B was very sad.

    # This makes a series of covariance matrices (one for each overlapping sequence of length min_periods)  
    # within the data we passed in (r_) that is about 2*min_periods in length - note that the number of cov  
    # matrices passed back is same as length of r_, but the dates whose index in the sequence is < min_periods  
    # are filled with NAs.  
    cmats = r_.ewm(halflife=_WINDOW * _EWM_HL, min_periods=_WINDOW).cov()  
    ncmat = cmats.shape[0]  
    # NOTE: upper limit in this loop is -1 rather than zero: so every value is calculated and recorded  
    #              EXCEPT for today, the first day of trading, which will be done separately after return...  
    for n in range(-_LTAVG_N, -1):  
        dt_idx = ncmat + n

        cmat = cmats[dt_idx, :, :].as_matrix()  

Chris:

The Python version is 2.7. The normal way to see the version is to do sys.version or something similar, but imports are restricted, so I couldn't find a way to do it.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Actually that's a whole other can o worms as 0.9 which I've been developing on (yes, I know 1.0 just released) requires 3.4. lots of other gotchas. Here's a fix:

import pandas as pd

# import-ANT thing to figure out here:  
pandas_version_num = list(map(int, pd.__version__.split('.')))  
# in case I run this in the far future:  
_PANDAS_MODERN_ = (pandas_version_num[0] > 0) or (pandas_version_num[1] >= 18)


###################################################################################################################  
# COMPATIBILITY!!!!  
# new un-deprecated syntax doesn't work in quantopian, try to future-proof this:  
def cov_ewm(df_, halflife, min_periods, nona=True):  
    #  NOTE: i discovered that the deprecated syntax actually works in 0.18.x but is going away...  
    if _PANDAS_MODERN_:  
        if nona:  
            covs = df_.ewm(halflife=halflife, min_periods=min_periods).cov().dropna()  
        else:  
            covs = df_.ewm(halflife=halflife, min_periods=min_periods).cov()  
    else:  
        if nona:  
            covs = pd.ewmcov(df_, halflife=halflife, min_periods=min_periods).dropna()  
        else:  
            covs = pd.ewmcov(df_, halflife=halflife, min_periods=min_periods)  
    return covs


###################################################################################################################