Skip to content

Commit a3f8508

Browse files
committed
CLN: fix flake8 warnings in pandas/stats
1 parent 81dfb28 commit a3f8508

14 files changed

+131
-80
lines changed

pandas/stats/api.py

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

55
# pylint: disable-msg=W0611,W0614,W0401
66

7+
# flake8: noqa
8+
79
from pandas.stats.moments import *
810
from pandas.stats.interface import ols
911
from pandas.stats.fama_macbeth import fama_macbeth

pandas/stats/common.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
2: 'expanding'
66
}
77
# also allow 'rolling' as key
8-
_WINDOW_TYPES.update((v, v) for k,v in list(_WINDOW_TYPES.items()))
8+
_WINDOW_TYPES.update((v, v) for k, v in list(_WINDOW_TYPES.items()))
99
_ADDITIONAL_CLUSTER_TYPES = set(("entity", "time"))
1010

11+
1112
def _get_cluster_type(cluster_type):
1213
# this was previous behavior
1314
if cluster_type is None:
@@ -20,15 +21,18 @@ def _get_cluster_type(cluster_type):
2021
return final_type
2122
raise ValueError('Unrecognized cluster type: %s' % cluster_type)
2223

24+
2325
def _get_window_type(window_type):
2426
# e.g., 0, 1, 2
2527
final_type = _WINDOW_TYPES.get(window_type)
2628
# e.g., 'full_sample'
27-
final_type = final_type or _WINDOW_TYPES.get(str(window_type).lower().replace(" ", "_"))
29+
final_type = final_type or _WINDOW_TYPES.get(
30+
str(window_type).lower().replace(" ", "_"))
2831
if final_type is None:
2932
raise ValueError('Unrecognized window type: %s' % window_type)
3033
return final_type
3134

35+
3236
def banner(text, width=80):
3337
"""
3438

pandas/stats/fama_macbeth.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import pandas.stats.common as common
88
from pandas.util.decorators import cache_readonly
99

10+
# flake8: noqa
1011

1112
def fama_macbeth(**kwargs):
1213
"""Runs Fama-MacBeth regression.
@@ -28,6 +29,7 @@ def fama_macbeth(**kwargs):
2829

2930

3031
class FamaMacBeth(StringMixin):
32+
3133
def __init__(self, y, x, intercept=True, nw_lags=None,
3234
nw_lags_beta=None,
3335
entity_effects=False, time_effects=False, x_effects=None,
@@ -39,7 +41,7 @@ def __init__(self, y, x, intercept=True, nw_lags=None,
3941
FutureWarning, stacklevel=4)
4042

4143
if dropped_dummies is None:
42-
dropped_dummies = {}
44+
dropped_dummies = {}
4345
self._nw_lags_beta = nw_lags_beta
4446

4547
from pandas.stats.plm import MovingPanelOLS
@@ -99,7 +101,7 @@ def _results(self):
99101
def _coef_table(self):
100102
buffer = StringIO()
101103
buffer.write('%13s %13s %13s %13s %13s %13s\n' %
102-
('Variable', 'Beta', 'Std Err', 't-stat', 'CI 2.5%', 'CI 97.5%'))
104+
('Variable', 'Beta', 'Std Err', 't-stat', 'CI 2.5%', 'CI 97.5%'))
103105
template = '%13s %13.4f %13.4f %13.2f %13.4f %13.4f\n'
104106

105107
for i, name in enumerate(self._cols):
@@ -148,12 +150,13 @@ def summary(self):
148150

149151

150152
class MovingFamaMacBeth(FamaMacBeth):
153+
151154
def __init__(self, y, x, window_type='rolling', window=10,
152155
intercept=True, nw_lags=None, nw_lags_beta=None,
153156
entity_effects=False, time_effects=False, x_effects=None,
154157
cluster=None, dropped_dummies=None, verbose=False):
155158
if dropped_dummies is None:
156-
dropped_dummies = {}
159+
dropped_dummies = {}
157160
self._window_type = common._get_window_type(window_type)
158161
self._window = window
159162

pandas/stats/interface.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def ols(**kwargs):
7676
result = ols(y=y, x=x)
7777
7878
# Run expanding panel OLS with window 10 and entity clustering.
79-
result = ols(y=y, x=x, cluster='entity', window_type='expanding', window=10)
79+
result = ols(y=y, x=x, cluster='entity', window_type='expanding',
80+
window=10)
8081
8182
Returns
8283
-------
@@ -85,12 +86,11 @@ def ols(**kwargs):
8586
"""
8687

8788
if (kwargs.get('cluster') is not None and
88-
kwargs.get('nw_lags') is not None):
89+
kwargs.get('nw_lags') is not None):
8990
raise ValueError(
9091
'Pandas OLS does not work with Newey-West correction '
9192
'and clustering.')
9293

93-
9494
pool = kwargs.get('pool')
9595
if 'pool' in kwargs:
9696
del kwargs['pool']

pandas/stats/misc.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
from pandas import compat
33
import numpy as np
44

5-
from pandas.core.api import Series, DataFrame, isnull, notnull
5+
from pandas.core.api import Series, DataFrame
66
from pandas.core.series import remove_na
7-
from pandas.compat import zip
7+
from pandas.compat import zip, lrange
8+
import pandas.core.common as com
89

910

1011
def zscore(series):
@@ -42,6 +43,7 @@ def correl_ts(frame1, frame2):
4243
def correl_xs(frame1, frame2):
4344
return correl_ts(frame1.T, frame2.T)
4445

46+
4547
def percentileofscore(a, score, kind='rank'):
4648
"""The percentile rank of a score relative to a list of scores.
4749
@@ -131,6 +133,7 @@ def percentileofscore(a, score, kind='rank'):
131133
else:
132134
raise ValueError("kind can only be 'rank', 'strict', 'weak' or 'mean'")
133135

136+
134137
def percentileRank(frame, column=None, kind='mean'):
135138
"""
136139
Return score at percentile for each point in time (cross-section)

0 commit comments

Comments
 (0)