Skip to content

Commit 4378153

Browse files
committed
DEPR: deprecate pandas.fama_macbeth, pandas-dev#6077
1 parent f67dd75 commit 4378153

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

doc/source/whatsnew/v0.18.0.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ Deprecations
253253
For example, instead of ``s.rolling(window=5,freq='D').max()`` to get the max value on a rolling 5 Day window, one could use ``s.resample('D',how='max').rolling(window=5).max()``, which first resamples the data to daily data, then provides a rolling 5 day window.
254254

255255
- ``pd.tseries.frequencies.get_offset_name`` function is deprecated. Use offset's ``.freqstr`` property as alternative (:issue:`11192`)
256+
- ``pandas.fama_macbeth`` routines are deprecated and will be removed in a future version (:issue:``)
256257

257258
.. _whatsnew_0180.prior_deprecations:
258259

@@ -345,5 +346,8 @@ Bug Fixes
345346
- Bug in ``read_excel`` failing to raise ``NotImplemented`` error when keywords `parse_dates` and `date_parser` are provided (:issue:`11544`)
346347

347348
- Bug in ``read_sql`` with pymysql connections failing to return chunked data (:issue:`11522`)
349+
<<<<<<< f67dd750a67e1e097b58407c755016d3726f21d5
348350

349-
- Bug in ``DataFrame`` when masking an empty ``DataFrame`` (:issue:`11859`)
351+
- Bug in ``DataFrame`` when masking an empty ``DataFrame`` (:issue:`11859`)
352+
=======
353+
>>>>>>> DEPR: deprecate pandas.fama_macbeth, #6077

pandas/stats/fama_macbeth.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def fama_macbeth(**kwargs):
1717
1818
nw_lags_beta: int
1919
Newey-West adjusts the betas by the given lags
20-
"""
20+
"""
2121
window_type = kwargs.get('window_type')
2222
if window_type is None:
2323
klass = FamaMacBeth
@@ -32,6 +32,12 @@ def __init__(self, y, x, intercept=True, nw_lags=None,
3232
nw_lags_beta=None,
3333
entity_effects=False, time_effects=False, x_effects=None,
3434
cluster=None, dropped_dummies=None, verbose=False):
35+
import warnings
36+
warnings.warn("The pandas.stats.fama_macbeth module is deprecated and will be "
37+
"removed in a future version. We refer to external packages "
38+
"like statsmodels. ",
39+
FutureWarning, stacklevel=4)
40+
3541
if dropped_dummies is None:
3642
dropped_dummies = {}
3743
self._nw_lags_beta = nw_lags_beta

pandas/stats/tests/test_fama_macbeth.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from pandas.compat import range
66
from pandas import compat
7+
import pandas.util.testing as tm
78
import numpy as np
89

910

@@ -23,8 +24,9 @@ def testFamaMacBethRolling(self):
2324
def checkFamaMacBethExtended(self, window_type, x, y, **kwds):
2425
window = 25
2526

26-
result = fama_macbeth(y=y, x=x, window_type=window_type, window=window,
27-
**kwds)
27+
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
28+
result = fama_macbeth(y=y, x=x, window_type=window_type, window=window,
29+
**kwds)
2830
self._check_stuff_works(result)
2931

3032
index = result._index
@@ -43,10 +45,12 @@ def checkFamaMacBethExtended(self, window_type, x, y, **kwds):
4345
x2[k] = v.truncate(start, end)
4446
y2 = y.truncate(start, end)
4547

46-
reference = fama_macbeth(y=y2, x=x2, **kwds)
48+
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
49+
reference = fama_macbeth(y=y2, x=x2, **kwds)
4750
assert_almost_equal(reference._stats, result._stats[:, i])
4851

49-
static = fama_macbeth(y=y2, x=x2, **kwds)
52+
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
53+
static = fama_macbeth(y=y2, x=x2, **kwds)
5054
self._check_stuff_works(static)
5155

5256
def _check_stuff_works(self, result):

0 commit comments

Comments
 (0)