Skip to content

Commit 074c8d2

Browse files
authored
Merge pull request statsmodels#5217 from jbrockmendel/npcompat3
MAINT: Remove outdated pandas compat shims
2 parents 8ea349b + d01c03e commit 074c8d2

File tree

6 files changed

+13
-24
lines changed

6 files changed

+13
-24
lines changed

examples/python/robust_models_1.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import matplotlib.pyplot as plt
88

99
import statsmodels.api as sm
10-
from statsmodels.compat.pandas import sort_values
1110

1211

1312
# * An M-estimator minimizes the function
@@ -233,12 +232,12 @@ def plot_weights(support, weights_func, xlabels, xticks):
233232

234233

235234
sidak = ols_model.outlier_test('sidak')
236-
sort_values(sidak, 'unadj_p', inplace=True)
235+
sidak.sort_values('unadj_p', inplace=True)
237236
print(sidak)
238237

239238

240239
fdr = ols_model.outlier_test('fdr_bh')
241-
sort_values(fdr, 'unadj_p', inplace=True)
240+
fdr.sort_values('unadj_p', inplace=True)
242241
print(fdr)
243242

244243

@@ -300,12 +299,12 @@ def plot_weights(support, weights_func, xlabels, xticks):
300299

301300

302301
sidak2 = ols_model.outlier_test('sidak')
303-
sort_values(sidak2, 'unadj_p', inplace=True)
302+
sidak2.sort_values('unadj_p', inplace=True)
304303
print(sidak2)
305304

306305

307306
fdr2 = ols_model.outlier_test('fdr_bh')
308-
sort_values(fdr2, 'unadj_p', inplace=True)
307+
fdr2.sort_values('unadj_p', inplace=True)
309308
print(fdr2)
310309

311310

statsmodels/compat/pandas.py

-5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
from distutils.version import LooseVersion
44

55
import pandas
6-
from pandas import RangeIndex, Float64Index # noqa:F401
76

87

98
version = LooseVersion(pandas.__version__)
109

1110

12-
def sort_values(df, *args, **kwargs):
13-
return df.sort_values(*args, **kwargs)
14-
15-
1611
try:
1712
from pandas.api.types import is_numeric_dtype # noqa:F401
1813
except ImportError:

statsmodels/graphics/tests/test_mosaicplot.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
# utilities for the tests
99

10-
from statsmodels.compat.pandas import sort_values
1110
from collections import OrderedDict
1211
from statsmodels.api import datasets
1312

@@ -110,7 +109,7 @@ def test_mosaic(close_figures):
110109
# sort by the marriage quality and give meaningful name
111110
# [rate_marriage, age, yrs_married, children,
112111
# religious, educ, occupation, occupation_husb]
113-
datas = sort_values(datas, ['rate_marriage', 'religious'])
112+
datas = datas.sort_values(['rate_marriage', 'religious'])
114113

115114
num_to_desc = {1: 'awful', 2: 'bad', 3: 'intermediate',
116115
4: 'good', 5: 'wonderful'}

statsmodels/imputation/ros.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
from scipy import stats
2020
import pandas
2121

22-
from statsmodels.compat.pandas import sort_values
23-
2422

2523
def _ros_sort(df, observations, censorship, warn=False):
2624
"""
@@ -53,8 +51,8 @@ def _ros_sort(df, observations, censorship, warn=False):
5351
"""
5452

5553
# separate uncensored data from censored data
56-
censored = sort_values(df[df[censorship]], observations, axis=0)
57-
uncensored = sort_values(df[~df[censorship]], observations, axis=0)
54+
censored = df[df[censorship]].sort_values(observations, axis=0)
55+
uncensored = df[~df[censorship]].sort_values(observations, axis=0)
5856

5957
if censored[observations].max() > uncensored[observations].max():
6058
censored = censored[censored[observations] <= uncensored[observations].max()]

statsmodels/sandbox/multilinear.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
more significant than outside the group.
1212
"""
1313

14-
from statsmodels.compat.pandas import sort_values
1514
from statsmodels.compat.python import iteritems, string_types
1615
from patsy import dmatrix
1716
import pandas as pd
@@ -172,7 +171,7 @@ def multiOLS(model, dataframe, column_list=None, method='fdr_bh',
172171
# mangle them togheter and sort by complexive p-value
173172
summary = pd.DataFrame(col_results)
174173
# order by the p-value: the most useful model first!
175-
summary = sort_values(summary.T, [('pvals', '_f_test')])
174+
summary = summary.T.sort_values([('pvals', '_f_test')])
176175
summary.index.name = 'endogenous vars'
177176
# implementing the pvalue correction method
178177
smt = stats.multipletests
@@ -317,7 +316,7 @@ def multigroup(pvals, groups, exact=True, keep_all=True, alpha=0.05):
317316
results['_in_non'][group_name] = res[2][1]
318317
results['_out_sign'][group_name] = res[2][2]
319318
results['_out_non'][group_name] = res[2][3]
320-
result_df = sort_values(pd.DataFrame(results), 'pvals')
319+
result_df = pd.DataFrame(results).sort_values('pvals')
321320
if not keep_all:
322321
result_df = result_df[result_df.increase]
323322
smt = stats.multipletests

statsmodels/tsa/base/tsa_model.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
from statsmodels.compat.python import lrange, long
2-
from statsmodels.compat.pandas import is_numeric_dtype, Float64Index
3-
4-
import datetime
1+
from statsmodels.compat.python import long
2+
from statsmodels.compat.pandas import is_numeric_dtype
53

64
import warnings
75
import numpy as np
86
from pandas import (to_datetime, Int64Index, DatetimeIndex, Period,
9-
PeriodIndex, RangeIndex, Timestamp, Series, Index)
7+
PeriodIndex, RangeIndex, Timestamp, Series, Index,
8+
Float64Index)
109
from pandas.tseries.frequencies import to_offset
1110

1211
from statsmodels.base import data

0 commit comments

Comments
 (0)