Skip to content

Commit cc6e059

Browse files
committed
CLN: move/reorg pandas.tools -> pandas.core.reshape
xref #13634
1 parent e0cbc37 commit cc6e059

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1548
-1544
lines changed

doc/source/whatsnew/v0.20.0.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ If indicated, a deprecation warning will be issued if you reference theses modul
13351335

13361336
.. csv-table::
13371337
:header: "Previous Location", "New Location", "Deprecated"
1338-
:widths: 30, 30, 4
1338+
:widths: 30, 30, 20
13391339

13401340
"pandas.lib", "pandas._libs.lib", "X"
13411341
"pandas.tslib", "pandas._libs.tslib", "X"
@@ -1349,6 +1349,7 @@ If indicated, a deprecation warning will be issued if you reference theses modul
13491349
"pandas.parser", "pandas.io.libparsers", "X"
13501350
"pandas.formats", "pandas.io.formats", ""
13511351
"pandas.sparse", "pandas.core.sparse", ""
1352+
"pandas.tools", "pandas.core.tools", "pandas.tools.plotting"
13521353
"pandas.types", "pandas.core.dtypes", ""
13531354
"pandas.io.sas.saslib", "pandas.io.sas.libsas", ""
13541355
"pandas._join", "pandas._libs.join", ""

pandas/__init__.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@
4444
from pandas.stats.api import *
4545
from pandas.tseries.api import *
4646
from pandas.core.computation.api import *
47-
48-
from pandas.tools.concat import concat
49-
from pandas.tools.merge import (merge, ordered_merge,
50-
merge_ordered, merge_asof)
51-
from pandas.tools.pivot import pivot_table, crosstab
47+
from pandas.core.reshape.api import *
5248

5349
# deprecate tools.plotting, plot_params and scatter_matrix on the top namespace
5450
import pandas.tools.plotting
@@ -58,9 +54,7 @@
5854
'pandas.scatter_matrix', pandas.plotting.scatter_matrix,
5955
'pandas.plotting.scatter_matrix')
6056

61-
from pandas.tools.tile import cut, qcut
62-
from pandas.tools.util import to_numeric
63-
from pandas.core.reshape import melt
57+
from pandas.core.reshape.util import to_numeric
6458
from pandas.util.print_versions import show_versions
6559
from pandas.io.api import *
6660
from pandas.util._tester import test

pandas/core/algorithms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ def value_counts(values, sort=True, ascending=False, normalize=False,
605605

606606
if bins is not None:
607607
try:
608-
from pandas.tools.tile import cut
608+
from pandas.core.reshape.tile import cut
609609
values = Series(values)
610610
ii = cut(values, bins, include_lowest=True)
611611
except TypeError:

pandas/core/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from pandas.core.frame import DataFrame
1919
from pandas.core.panel import Panel, WidePanel
2020
from pandas.core.panel4d import Panel4D
21-
from pandas.core.reshape import (pivot_simple as pivot, get_dummies,
21+
from pandas.core.reshape.reshape import (pivot_simple as pivot, get_dummies,
2222
lreshape, wide_to_long)
2323

2424
from pandas.core.indexing import IndexSlice

pandas/core/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def nested_renaming_depr(level=4):
522522
len(obj.columns.intersection(keys)) != len(keys)):
523523
nested_renaming_depr()
524524

525-
from pandas.tools.concat import concat
525+
from pandas.core.reshape.concat import concat
526526

527527
def _agg_1dim(name, how, subset=None):
528528
"""
@@ -671,7 +671,7 @@ def is_any_frame():
671671
return result, True
672672

673673
def _aggregate_multiple_funcs(self, arg, _level, _axis):
674-
from pandas.tools.concat import concat
674+
from pandas.core.reshape.concat import concat
675675

676676
if _axis != 0:
677677
raise NotImplementedError("axis other than 0 is not supported")

pandas/core/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,7 @@ def describe(self):
19951995
counts = self.value_counts(dropna=False)
19961996
freqs = counts / float(counts.sum())
19971997

1998-
from pandas.tools.concat import concat
1998+
from pandas.core.reshape.concat import concat
19991999
result = concat([counts, freqs], axis=1)
20002000
result.columns = ['counts', 'freqs']
20012001
result.index.name = 'categories'

pandas/core/computation/expr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pandas.core.base import StringMixin
1414
from pandas.core import common as com
1515
import pandas.io.formats.printing as printing
16-
from pandas.tools.util import compose
16+
from pandas.core.reshape.util import compose
1717
from pandas.core.computation.ops import (
1818
_cmp_ops_syms, _bool_ops_syms,
1919
_arith_ops_syms, _unary_ops_syms, is_term)

pandas/core/frame.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -3956,7 +3956,7 @@ def pivot(self, index=None, columns=None, values=None):
39563956
39573957
39583958
"""
3959-
from pandas.core.reshape import pivot
3959+
from pandas.core.reshape.reshape import pivot
39603960
return pivot(self, index=index, columns=columns, values=values)
39613961

39623962
def stack(self, level=-1, dropna=True):
@@ -3992,7 +3992,7 @@ def stack(self, level=-1, dropna=True):
39923992
-------
39933993
stacked : DataFrame or Series
39943994
"""
3995-
from pandas.core.reshape import stack, stack_multiple
3995+
from pandas.core.reshape.reshape import stack, stack_multiple
39963996

39973997
if isinstance(level, (tuple, list)):
39983998
return stack_multiple(self, level, dropna=dropna)
@@ -4057,7 +4057,7 @@ def unstack(self, level=-1, fill_value=None):
40574057
-------
40584058
unstacked : DataFrame or Series
40594059
"""
4060-
from pandas.core.reshape import unstack
4060+
from pandas.core.reshape.reshape import unstack
40614061
return unstack(self, level, fill_value)
40624062

40634063
_shared_docs['melt'] = ("""
@@ -4159,7 +4159,7 @@ def unstack(self, level=-1, fill_value=None):
41594159
other='melt'))
41604160
def melt(self, id_vars=None, value_vars=None, var_name=None,
41614161
value_name='value', col_level=None):
4162-
from pandas.core.reshape import melt
4162+
from pandas.core.reshape.reshape import melt
41634163
return melt(self, id_vars=id_vars, value_vars=value_vars,
41644164
var_name=var_name, value_name=value_name,
41654165
col_level=col_level)
@@ -4609,7 +4609,7 @@ def append(self, other, ignore_index=False, verify_integrity=False):
46094609
if (self.columns.get_indexer(other.columns) >= 0).all():
46104610
other = other.loc[:, self.columns]
46114611

4612-
from pandas.tools.concat import concat
4612+
from pandas.core.reshape.concat import concat
46134613
if isinstance(other, (list, tuple)):
46144614
to_concat = [self] + other
46154615
else:
@@ -4741,8 +4741,8 @@ def join(self, other, on=None, how='left', lsuffix='', rsuffix='',
47414741

47424742
def _join_compat(self, other, on=None, how='left', lsuffix='', rsuffix='',
47434743
sort=False):
4744-
from pandas.tools.merge import merge
4745-
from pandas.tools.concat import concat
4744+
from pandas.core.reshape.merge import merge
4745+
from pandas.core.reshape.concat import concat
47464746

47474747
if isinstance(other, Series):
47484748
if other.name is None:
@@ -4786,7 +4786,7 @@ def _join_compat(self, other, on=None, how='left', lsuffix='', rsuffix='',
47864786
def merge(self, right, how='inner', on=None, left_on=None, right_on=None,
47874787
left_index=False, right_index=False, sort=False,
47884788
suffixes=('_x', '_y'), copy=True, indicator=False):
4789-
from pandas.tools.merge import merge
4789+
from pandas.core.reshape.merge import merge
47904790
return merge(self, right, how=how, on=on, left_on=left_on,
47914791
right_on=right_on, left_index=left_index,
47924792
right_index=right_index, sort=sort, suffixes=suffixes,
@@ -4846,7 +4846,7 @@ def round(self, decimals=0, *args, **kwargs):
48464846
Series.round
48474847
48484848
"""
4849-
from pandas.tools.concat import concat
4849+
from pandas.core.reshape.concat import concat
48504850

48514851
def _dict_round(df, decimals):
48524852
for col, vals in df.iteritems():
@@ -5523,7 +5523,7 @@ def isin(self, values):
55235523
"""
55245524
if isinstance(values, dict):
55255525
from collections import defaultdict
5526-
from pandas.tools.concat import concat
5526+
from pandas.core.reshape.concat import concat
55275527
values = defaultdict(list, values)
55285528
return concat((self.iloc[:, [i]].isin(values[col])
55295529
for i, col in enumerate(self.columns)), axis=1)

pandas/core/groupby.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ def _wrap_applied_output(self, *args, **kwargs):
870870
raise AbstractMethodError(self)
871871

872872
def _concat_objects(self, keys, values, not_indexed_same=False):
873-
from pandas.tools.concat import concat
873+
from pandas.core.reshape.concat import concat
874874

875875
def reset_identity(values):
876876
# reset the identities of the components
@@ -2985,7 +2985,7 @@ def transform(self, func, *args, **kwargs):
29852985
s = klass(res, indexer)
29862986
results.append(s)
29872987

2988-
from pandas.tools.concat import concat
2988+
from pandas.core.reshape.concat import concat
29892989
result = concat(results).sort_index()
29902990

29912991
# we will only try to coerce the result type if
@@ -3126,8 +3126,8 @@ def value_counts(self, normalize=False, sort=True, ascending=False,
31263126
bins=None, dropna=True):
31273127

31283128
from functools import partial
3129-
from pandas.tools.tile import cut
3130-
from pandas.tools.merge import _get_join_indexers
3129+
from pandas.core.reshape.tile import cut
3130+
from pandas.core.reshape.merge import _get_join_indexers
31313131

31323132
if bins is not None and not np.iterable(bins):
31333133
# scalar bins cannot be done at top level
@@ -3509,7 +3509,7 @@ def _decide_output_index(self, output, labels):
35093509

35103510
def _wrap_applied_output(self, keys, values, not_indexed_same=False):
35113511
from pandas.core.index import _all_indexes_same
3512-
from pandas.tools.util import to_numeric
3512+
from pandas.core.reshape.util import to_numeric
35133513

35143514
if len(keys) == 0:
35153515
return DataFrame(index=keys)
@@ -3600,7 +3600,7 @@ def first_non_None_value(values):
36003600
# still a series
36013601
# path added as of GH 5545
36023602
elif all_indexed_same:
3603-
from pandas.tools.concat import concat
3603+
from pandas.core.reshape.concat import concat
36043604
return concat(values)
36053605

36063606
if not all_indexed_same:
@@ -3633,7 +3633,7 @@ def first_non_None_value(values):
36333633
else:
36343634
# GH5788 instead of stacking; concat gets the
36353635
# dtypes correct
3636-
from pandas.tools.concat import concat
3636+
from pandas.core.reshape.concat import concat
36373637
result = concat(values, keys=key_index,
36383638
names=key_index.names,
36393639
axis=self.axis).unstack()
@@ -3684,7 +3684,7 @@ def first_non_None_value(values):
36843684
not_indexed_same=not_indexed_same)
36853685

36863686
def _transform_general(self, func, *args, **kwargs):
3687-
from pandas.tools.concat import concat
3687+
from pandas.core.reshape.concat import concat
36883688

36893689
applied = []
36903690
obj = self._obj_with_exclusions
@@ -4071,7 +4071,7 @@ def _iterate_column_groupbys(self):
40714071
exclusions=self.exclusions)
40724072

40734073
def _apply_to_column_groupbys(self, func):
4074-
from pandas.tools.concat import concat
4074+
from pandas.core.reshape.concat import concat
40754075
return concat(
40764076
(func(col_groupby) for _, col_groupby
40774077
in self._iterate_column_groupbys()),
@@ -4151,7 +4151,7 @@ def groupby_series(obj, col=None):
41514151
if isinstance(obj, Series):
41524152
results = groupby_series(obj)
41534153
else:
4154-
from pandas.tools.concat import concat
4154+
from pandas.core.reshape.concat import concat
41554155
results = [groupby_series(obj[col], col) for col in obj.columns]
41564156
results = concat(results, axis=1)
41574157

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3064,7 +3064,7 @@ def _join_multi(self, other, how, return_indexers=True):
30643064
"implemented")
30653065

30663066
def _join_non_unique(self, other, how='left', return_indexers=False):
3067-
from pandas.tools.merge import _get_join_indexers
3067+
from pandas.core.reshape.merge import _get_join_indexers
30683068

30693069
left_idx, right_idx = _get_join_indexers([self.values],
30703070
[other._values], how=how,

pandas/core/indexes/multi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ def from_product(cls, iterables, sortorder=None, names=None):
11701170
MultiIndex.from_tuples : Convert list of tuples to MultiIndex
11711171
"""
11721172
from pandas.core.categorical import _factorize_from_iterables
1173-
from pandas.tools.util import cartesian_product
1173+
from pandas.core.reshape.util import cartesian_product
11741174

11751175
labels, levels = _factorize_from_iterables(iterables)
11761176
labels = cartesian_product(labels)

pandas/core/panel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
create_block_manager_from_blocks)
3434
from pandas.core.ops import _op_descriptions
3535
from pandas.core.series import Series
36-
from pandas.tools.util import cartesian_product
36+
from pandas.core.reshape.util import cartesian_product
3737
from pandas.util.decorators import (deprecate, Appender)
3838

3939
_shared_doc_kwargs = dict(
@@ -1294,7 +1294,7 @@ def join(self, other, how='left', lsuffix='', rsuffix=''):
12941294
-------
12951295
joined : Panel
12961296
"""
1297-
from pandas.tools.concat import concat
1297+
from pandas.core.reshape.concat import concat
12981298

12991299
if isinstance(other, Panel):
13001300
join_major, join_minor = self._get_join_index(other, how)
File renamed without changes.

pandas/core/reshape/api.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from pandas.core.reshape.concat import concat
2+
from pandas.core.reshape.reshape import melt
3+
from pandas.core.reshape.merge import merge, ordered_merge, merge_ordered, merge_asof
4+
from pandas.core.reshape.pivot import pivot_table, crosstab
5+
from pandas.core.reshape.tile import cut, qcut
File renamed without changes.

0 commit comments

Comments
 (0)