Skip to content

Commit fcc256b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into delay-import
2 parents 6df1753 + db1206a commit fcc256b

15 files changed

+69
-36
lines changed

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ install:
5959

6060
# install our build environment
6161
- cmd: conda config --set show_channel_urls true --set always_yes true --set changeps1 false
62-
- cmd: conda update -q conda
62+
# - cmd: conda update -q conda
6363
- cmd: conda config --set ssl_verify false
6464

6565
# add the pandas channel *before* defaults to have defaults take priority

ci/install.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $MINICONDA_URL = "http://repo.continuum.io/miniconda/"
77

88
function DownloadMiniconda ($python_version, $platform_suffix) {
99
$webclient = New-Object System.Net.WebClient
10-
$filename = "Miniconda3-latest-Windows-" + $platform_suffix + ".exe"
10+
$filename = "Miniconda3-4.3.21-Windows-" + $platform_suffix + ".exe"
1111
$url = $MINICONDA_URL + $filename
1212

1313
$basedir = $pwd.Path + "\"
@@ -85,7 +85,7 @@ function UpdateConda ($python_home) {
8585

8686
function main () {
8787
InstallMiniconda "3.5" $env:PYTHON_ARCH $env:CONDA_ROOT
88-
UpdateConda $env:CONDA_ROOT
88+
# UpdateConda $env:CONDA_ROOT
8989
InstallCondaPackages $env:CONDA_ROOT "conda-build jinja2 anaconda-client"
9090
}
9191

ci/install_circle.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ echo "[Using clean Miniconda install]"
1010
rm -rf "$MINICONDA_DIR"
1111

1212
# install miniconda
13-
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -q -O miniconda.sh || exit 1
13+
# wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -q -O miniconda.sh || exit 1
14+
# Pin miniconda
15+
wget https://repo.continuum.io/miniconda/Miniconda2-4.3.21-Linux-x86_64.sh -q -O miniconda.sh || exit 1
1416
bash miniconda.sh -b -p "$MINICONDA_DIR" || exit 1
1517

1618
export PATH="$MINICONDA_DIR/bin:$PATH"
1719

1820
echo "[update conda]"
1921
conda config --set ssl_verify false || exit 1
2022
conda config --set always_yes true --set changeps1 false || exit 1
21-
conda update -q conda
23+
# conda update -q conda
2224

2325
# add the pandas channel to take priority
2426
# to add extra packages

ci/install_travis.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ fi
3434

3535
# install miniconda
3636
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
37-
time wget http://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh || exit 1
37+
# temporarily pin miniconda
38+
# time wget http://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh || exit 1
39+
time wget https://repo.continuum.io/miniconda/Miniconda2-4.3.21-MacOSX-x86_64.sh -O miniconda.sh || exit 1
3840
else
39-
time wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh || exit 1
41+
# temporarily pin miniconda
42+
# time wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh || exit 1
43+
time wget https://repo.continuum.io/miniconda/Miniconda2-4.3.21-Linux-x86_64.sh -O miniconda.sh || exit 1
4044
fi
4145
time bash miniconda.sh -b -p "$MINICONDA_DIR" || exit 1
4246

@@ -48,7 +52,7 @@ echo
4852
echo "[update conda]"
4953
conda config --set ssl_verify false || exit 1
5054
conda config --set quiet true --set always_yes true --set changeps1 false || exit 1
51-
conda update -q conda
55+
# conda update -q conda
5256

5357
echo
5458
echo "[add channels]"

ci/requirements-2.7_SLOW.run

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ s3fs
1616
psycopg2
1717
pymysql
1818
html5lib
19-
beautiful-soup
19+
beautifulsoup4

ci/requirements-2.7_WIN.run

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ xlsxwriter
1414
s3fs
1515
bottleneck
1616
html5lib
17-
beautiful-soup
17+
beautifulsoup4
1818
jinja2=2.8

ci/requirements_all.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ xlrd
1313
xlwt
1414
html5lib
1515
patsy
16-
beautiful-soup
16+
beautifulsoup4
1717
numpy
1818
cython
1919
scipy

doc/source/whatsnew/v0.21.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ Deprecations
492492
- ``pd.options.html.border`` has been deprecated in favor of ``pd.options.display.html.border`` (:issue:`15793`).
493493
- :func:`SeriesGroupBy.nth` has deprecated ``True`` in favor of ``'all'`` for its kwarg ``dropna`` (:issue:`11038`).
494494
- :func:`DataFrame.as_blocks` is deprecated, as this is exposing the internal implementation (:issue:`17302`)
495+
- ``pd.TimeGrouper`` is deprecated in favor of :class:`pandas.Grouper` (:issue:`16747`)
495496

496497
.. _whatsnew_0210.deprecations.argmin_min
497498

pandas/core/api.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from pandas.tseries.offsets import DateOffset
3434
from pandas.core.tools.datetimes import to_datetime
3535
from pandas.core.tools.timedeltas import to_timedelta
36-
from pandas.core.resample import TimeGrouper
3736

3837
# see gh-14094.
3938
from pandas.util._depr_module import _DeprecatedModule
@@ -52,8 +51,8 @@
5251

5352
# deprecation, xref #13790
5453
def match(*args, **kwargs):
55-
import warnings
5654

55+
import warnings
5756
warnings.warn("pd.match() is deprecated and will be removed "
5857
"in a future version",
5958
FutureWarning, stacklevel=2)
@@ -64,8 +63,20 @@ def match(*args, **kwargs):
6463
def groupby(*args, **kwargs):
6564
import warnings
6665

67-
warnings.warn("pd.groupby() is deprecated and will be removed "
66+
warnings.warn("pd.groupby() is deprecated and will be removed; "
6867
"Please use the Series.groupby() or "
6968
"DataFrame.groupby() methods",
7069
FutureWarning, stacklevel=2)
7170
return args[0].groupby(*args[1:], **kwargs)
71+
72+
73+
# deprecation, xref
74+
class TimeGrouper(object):
75+
76+
def __new__(cls, *args, **kwargs):
77+
from pandas.core.resample import TimeGrouper
78+
import warnings
79+
warnings.warn("pd.TimeGrouper is deprecated and will be removed; "
80+
"Please use pd.Grouper(freq=...)",
81+
FutureWarning, stacklevel=2)
82+
return TimeGrouper(*args, **kwargs)

pandas/tests/api/test_api.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ class TestPDApi(Base):
4747
'Grouper', 'HDFStore', 'Index', 'Int64Index', 'MultiIndex',
4848
'Period', 'PeriodIndex', 'RangeIndex', 'UInt64Index',
4949
'Series', 'SparseArray', 'SparseDataFrame',
50-
'SparseSeries', 'TimeGrouper', 'Timedelta',
50+
'SparseSeries', 'Timedelta',
5151
'TimedeltaIndex', 'Timestamp', 'Interval', 'IntervalIndex']
5252

5353
# these are already deprecated; awaiting removal
54-
deprecated_classes = ['WidePanel', 'Panel4D',
54+
deprecated_classes = ['WidePanel', 'Panel4D', 'TimeGrouper',
5555
'SparseList', 'Expr', 'Term']
5656

5757
# these should be deprecated in the future
@@ -184,6 +184,11 @@ def test_groupby(self):
184184
check_stacklevel=False):
185185
pd.groupby(pd.Series([1, 2, 3]), [1, 1, 1])
186186

187+
def test_TimeGrouper(self):
188+
with tm.assert_produces_warning(FutureWarning,
189+
check_stacklevel=False):
190+
pd.TimeGrouper(freq='D')
191+
187192
# GH 15940
188193

189194
def test_get_store(self):

pandas/tests/groupby/test_groupby.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -3335,7 +3335,7 @@ def test_groupby_with_empty(self):
33353335
index = pd.DatetimeIndex(())
33363336
data = ()
33373337
series = pd.Series(data, index)
3338-
grouper = pd.core.resample.TimeGrouper('D')
3338+
grouper = pd.Grouper(freq='D')
33393339
grouped = series.groupby(grouper)
33403340
assert next(iter(grouped), None) is None
33413341

@@ -3354,7 +3354,7 @@ def test_groupby_with_small_elem(self):
33543354
df = pd.DataFrame({'event': ['start', 'start'],
33553355
'change': [1234, 5678]},
33563356
index=pd.DatetimeIndex(['2014-09-10', '2013-10-10']))
3357-
grouped = df.groupby([pd.TimeGrouper(freq='M'), 'event'])
3357+
grouped = df.groupby([pd.Grouper(freq='M'), 'event'])
33583358
assert len(grouped.groups) == 2
33593359
assert grouped.ngroups == 2
33603360
assert (pd.Timestamp('2014-09-30'), 'start') in grouped.groups
@@ -3369,7 +3369,7 @@ def test_groupby_with_small_elem(self):
33693369
'change': [1234, 5678, 9123]},
33703370
index=pd.DatetimeIndex(['2014-09-10', '2013-10-10',
33713371
'2014-09-15']))
3372-
grouped = df.groupby([pd.TimeGrouper(freq='M'), 'event'])
3372+
grouped = df.groupby([pd.Grouper(freq='M'), 'event'])
33733373
assert len(grouped.groups) == 2
33743374
assert grouped.ngroups == 2
33753375
assert (pd.Timestamp('2014-09-30'), 'start') in grouped.groups
@@ -3385,7 +3385,7 @@ def test_groupby_with_small_elem(self):
33853385
'change': [1234, 5678, 9123]},
33863386
index=pd.DatetimeIndex(['2014-09-10', '2013-10-10',
33873387
'2014-08-05']))
3388-
grouped = df.groupby([pd.TimeGrouper(freq='M'), 'event'])
3388+
grouped = df.groupby([pd.Grouper(freq='M'), 'event'])
33893389
assert len(grouped.groups) == 3
33903390
assert grouped.ngroups == 3
33913391
assert (pd.Timestamp('2014-09-30'), 'start') in grouped.groups
@@ -3682,9 +3682,9 @@ def test_nunique_with_timegrouper(self):
36823682
Timestamp('2016-06-28 16:09:30'),
36833683
Timestamp('2016-06-28 16:46:28')],
36843684
'data': ['1', '2', '3']}).set_index('time')
3685-
result = test.groupby(pd.TimeGrouper(freq='h'))['data'].nunique()
3685+
result = test.groupby(pd.Grouper(freq='h'))['data'].nunique()
36863686
expected = test.groupby(
3687-
pd.TimeGrouper(freq='h')
3687+
pd.Grouper(freq='h')
36883688
)['data'].apply(pd.Series.nunique)
36893689
tm.assert_series_equal(result, expected)
36903690

pandas/tests/groupby/test_timegrouper.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ def test_groupby_with_timegrouper(self):
5252
assert_frame_equal(result1, expected)
5353

5454
df_sorted = df.sort_index()
55-
result2 = df_sorted.groupby(pd.TimeGrouper(freq='5D')).sum()
55+
result2 = df_sorted.groupby(pd.Grouper(freq='5D')).sum()
5656
assert_frame_equal(result2, expected)
5757

58-
result3 = df.groupby(pd.TimeGrouper(freq='5D')).sum()
58+
result3 = df.groupby(pd.Grouper(freq='5D')).sum()
5959
assert_frame_equal(result3, expected)
6060

6161
def test_groupby_with_timegrouper_methods(self):
@@ -80,7 +80,7 @@ def test_groupby_with_timegrouper_methods(self):
8080

8181
for df in [df_original, df_sorted]:
8282
df = df.set_index('Date', drop=False)
83-
g = df.groupby(pd.TimeGrouper('6M'))
83+
g = df.groupby(pd.Grouper(freq='6M'))
8484
assert g.group_keys
8585
assert isinstance(g.grouper, pd.core.groupby.BinGrouper)
8686
groups = g.groups
@@ -265,11 +265,11 @@ def test_timegrouper_with_reg_groups(self):
265265
['date', 'user_id']).sort_index().astype('int64')
266266
expected.name = 'whole_cost'
267267

268-
result1 = df.sort_index().groupby([pd.TimeGrouper(freq=freq),
268+
result1 = df.sort_index().groupby([pd.Grouper(freq=freq),
269269
'user_id'])['whole_cost'].sum()
270270
assert_series_equal(result1, expected)
271271

272-
result2 = df.groupby([pd.TimeGrouper(freq=freq), 'user_id'])[
272+
result2 = df.groupby([pd.Grouper(freq=freq), 'user_id'])[
273273
'whole_cost'].sum()
274274
assert_series_equal(result2, expected)
275275

@@ -340,7 +340,7 @@ def sumfunc_series(x):
340340
return pd.Series([x['value'].sum()], ('sum',))
341341

342342
expected = df.groupby(pd.Grouper(key='date')).apply(sumfunc_series)
343-
result = (df_dt.groupby(pd.TimeGrouper(freq='M', key='date'))
343+
result = (df_dt.groupby(pd.Grouper(freq='M', key='date'))
344344
.apply(sumfunc_series))
345345
assert_frame_equal(result.reset_index(drop=True),
346346
expected.reset_index(drop=True))
@@ -358,8 +358,10 @@ def sumfunc_value(x):
358358
return x.value.sum()
359359

360360
expected = df.groupby(pd.Grouper(key='date')).apply(sumfunc_value)
361-
result = (df_dt.groupby(pd.TimeGrouper(freq='M', key='date'))
362-
.apply(sumfunc_value))
361+
with tm.assert_produces_warning(FutureWarning,
362+
check_stacklevel=False):
363+
result = (df_dt.groupby(pd.TimeGrouper(freq='M', key='date'))
364+
.apply(sumfunc_value))
363365
assert_series_equal(result.reset_index(drop=True),
364366
expected.reset_index(drop=True))
365367

@@ -617,7 +619,7 @@ def test_nunique_with_timegrouper_and_nat(self):
617619
Timestamp('2016-06-28 16:46:28')],
618620
'data': ['1', '2', '3']})
619621

620-
grouper = pd.TimeGrouper(key='time', freq='h')
622+
grouper = pd.Grouper(key='time', freq='h')
621623
result = test.groupby(grouper)['data'].nunique()
622624
expected = test[test.time.notnull()].groupby(grouper)['data'].nunique()
623625
tm.assert_series_equal(result, expected)

pandas/tests/groupby/test_transform.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def demean(arr):
5757

5858
# GH 8430
5959
df = tm.makeTimeDataFrame()
60-
g = df.groupby(pd.TimeGrouper('M'))
60+
g = df.groupby(pd.Grouper(freq='M'))
6161
g.transform(lambda x: x - 1)
6262

6363
# GH 9700

pandas/tests/io/test_pytables.py

+4
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,10 @@ def test_complibs(self):
799799
# Remove lzo if its not available on this platform
800800
if not tables.which_lib_version('lzo'):
801801
all_complibs.remove('lzo')
802+
# Remove bzip2 if its not available on this platform
803+
if not tables.which_lib_version("bzip2"):
804+
all_complibs.remove("bzip2")
805+
802806
all_levels = range(0, 10)
803807
all_tests = [(lib, lvl) for lib in all_complibs for lvl in all_levels]
804808

pandas/tests/test_resample.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1983,8 +1983,8 @@ def test_resample_nunique(self):
19831983
pd.Timestamp('2015-06-08 00:00:00'): '2015-06-08'}})
19841984
r = df.resample('D')
19851985
g = df.groupby(pd.Grouper(freq='D'))
1986-
expected = df.groupby(pd.TimeGrouper('D')).ID.apply(lambda x:
1987-
x.nunique())
1986+
expected = df.groupby(pd.Grouper(freq='D')).ID.apply(lambda x:
1987+
x.nunique())
19881988
assert expected.name == 'ID'
19891989

19901990
for t in [r, g]:
@@ -3075,7 +3075,9 @@ def setup_method(self, method):
30753075
index=date_range('1/1/2000', periods=1000))
30763076

30773077
def test_apply(self):
3078-
grouper = TimeGrouper('A', label='right', closed='right')
3078+
with tm.assert_produces_warning(FutureWarning,
3079+
check_stacklevel=False):
3080+
grouper = pd.TimeGrouper(freq='A', label='right', closed='right')
30793081

30803082
grouped = self.ts.groupby(grouper)
30813083

@@ -3093,7 +3095,9 @@ def test_count(self):
30933095

30943096
expected = self.ts.groupby(lambda x: x.year).count()
30953097

3096-
grouper = TimeGrouper('A', label='right', closed='right')
3098+
with tm.assert_produces_warning(FutureWarning,
3099+
check_stacklevel=False):
3100+
grouper = pd.TimeGrouper(freq='A', label='right', closed='right')
30973101
result = self.ts.groupby(grouper).count()
30983102
expected.index = result.index
30993103
assert_series_equal(result, expected)

0 commit comments

Comments
 (0)