From a4e2ee5d1d7f1d7c6c91b18124ffdd29958b1ad2 Mon Sep 17 00:00:00 2001 From: Webb Sledge Date: Sat, 2 Nov 2024 22:09:26 -0400 Subject: [PATCH] Fix deprecation warning in Pandas method 'pct_change' --- pypfopt/expected_returns.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pypfopt/expected_returns.py b/pypfopt/expected_returns.py index 92d57e66..ac7fb70c 100644 --- a/pypfopt/expected_returns.py +++ b/pypfopt/expected_returns.py @@ -51,9 +51,9 @@ def returns_from_prices(prices, log_returns=False): :rtype: pd.DataFrame """ if log_returns: - returns = np.log(1 + prices.pct_change()).dropna(how="all") + returns = np.log(1 + prices.pct_change(fill_method=None)).dropna(how="all") else: - returns = prices.pct_change().dropna(how="all") + returns = prices.pct_change(fill_method=None).dropna(how="all") return returns