Skip to content

Commit b026b4e

Browse files
authored
Fix for pandas 1.0 (#124)
* as_matrix was depricated then removed. to_numpy() works in this situation * updated travis to include pandas 1.0.x, python 3.7 numpy 1.18 and scipy 1.4.x - kept a python 2.7 with the last supported versions of pydata. * versions compatible with conda for travis * old scipy and numpy * old scipy and numpy * old scipy and numpy * old scipy and numpy * old scipy and numpy * old scipy and numpy * who uses 3.5 anyway * Fix for pandas 1.0 * as_matrix was deprecated then removed. to_numpy() works in this situation * updated travis to include pandas 1.0.x, python 3.7 numpy 1.18 and scipy 1.4.x * kept a python 2.7 build with the last supported versions of pydata. * versions compatible with conda for travis * try except branch to support old pandas as required by zipline * as_matrix() not to_matrix() - thanks again Travis. Co-authored-by: Rich Atkinson <[email protected]>
1 parent b561c5f commit b026b4e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

.travis.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ sudo: false
44
matrix:
55
include:
66
- python: 2.7
7-
env: PANDAS_VERSION=0.18.1 NUMPY_VERSION=1.11.1 SCIPY_VERSION=0.17.1 LIBGFORTRAN_VERSION=3.0
8-
- python: 2.7
9-
env: PANDAS_VERSION=0.19.2 NUMPY_VERSION=1.12.1 SCIPY_VERSION=0.19.0 LIBGFORTRAN_VERSION=3.0
7+
env: PANDAS_VERSION=0.24.2 NUMPY_VERSION=1.12.1 SCIPY_VERSION=1.2.1 LIBGFORTRAN_VERSION=3.0
108
- python: 2.7
119
env: PANDAS_VERSION=0.20.1 NUMPY_VERSION=1.12.1 SCIPY_VERSION=0.19.0 LIBGFORTRAN_VERSION=3.0
12-
- python: 3.5
13-
env: PANDAS_VERSION=0.18.1 NUMPY_VERSION=1.11.1 SCIPY_VERSION=0.17.1 LIBGFORTRAN_VERSION=3.0
14-
- python: 3.5
15-
env: PANDAS_VERSION=0.19.2 NUMPY_VERSION=1.12.1 SCIPY_VERSION=0.19.0 LIBGFORTRAN_VERSION=3.0
10+
- python: 3.6
11+
env: PANDAS_VERSION=1.0.4 NUMPY_VERSION=1.18.4 SCIPY_VERSION=1.4.1 LIBGFORTRAN_VERSION=3.0
1612
- python: 3.6
1713
env: PANDAS_VERSION=0.20.1 NUMPY_VERSION=1.12.1 SCIPY_VERSION=0.19.0 LIBGFORTRAN_VERSION=3.0
14+
- python: 3.6
15+
env: PANDAS_VERSION=1.0.4 NUMPY_VERSION=1.18.4 SCIPY_VERSION=1.4.1 LIBGFORTRAN_VERSION=3.0
16+
- python: 3.7
17+
env: PANDAS_VERSION=1.0.4 NUMPY_VERSION=1.18.4 SCIPY_VERSION=1.4.1 LIBGFORTRAN_VERSION=3.0
1818

1919
before_install:
2020
# We do this conditionally because it saves us some downloading if the

empyrical/stats.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,13 @@ def gpd_risk_estimates_aligned(returns, var_p=0.01):
17471747

17481748
DEFAULT_THRESHOLD = 0.2
17491749
MINIMUM_THRESHOLD = 0.000000001
1750-
returns_array = pd.Series(returns).as_matrix()
1750+
1751+
try:
1752+
returns_array = pd.Series(returns).to_numpy()
1753+
except AttributeError:
1754+
# while zipline requires support for pandas < 0.25
1755+
returns_array = pd.Series(returns).as_matrix()
1756+
17511757
flipped_returns = -1 * returns_array
17521758
losses = flipped_returns[flipped_returns > 0]
17531759
threshold = DEFAULT_THRESHOLD

0 commit comments

Comments
 (0)