Skip to content

Commit

Permalink
CLN: strip out and form tools/concat.py from tools/merge.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed Feb 9, 2017
1 parent c23b1a4 commit ba34c51
Show file tree
Hide file tree
Showing 21 changed files with 672 additions and 657 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ Deprecations
- ``TimedeltaIndex.searchsorted()``, ``DatetimeIndex.searchsorted()``, and ``PeriodIndex.searchsorted()`` have deprecated the ``key`` parameter in favor of ``value`` (:issue:`12662`)
- ``DataFrame.astype()`` has deprecated the ``raise_on_error`` parameter in favor of ``errors`` (:issue:`14878`)
- ``Series.sortlevel`` and ``DataFrame.sortlevel`` have been deprecated in favor of ``Series.sort_index`` and ``DataFrame.sort_index`` (:issue:`15099`)

- importing ``concat`` from ``pandas.tools.merge`` has been deprecated in favor of imports from the ``pandas`` namespace. This should only affect explict imports (:issue:`15358`)

.. _whatsnew_0200.prior_deprecations:

Expand Down
6 changes: 4 additions & 2 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
from pandas.sparse.api import *
from pandas.stats.api import *
from pandas.tseries.api import *
from pandas.io.api import *
from pandas.computation.api import *

from pandas.tools.merge import (merge, concat, ordered_merge,
from pandas.tools.concat import concat
from pandas.tools.merge import (merge, ordered_merge,
merge_ordered, merge_asof)
from pandas.tools.pivot import pivot_table, crosstab
from pandas.tools.plotting import scatter_matrix, plot_params
Expand All @@ -54,6 +54,8 @@
from pandas.core.reshape import melt
from pandas.util.print_versions import show_versions

from pandas.io.api import *

# define the testing framework
import pandas.util.testing
from pandas.util.nosetester import NoseTester
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def _aggregate(self, arg, *args, **kwargs):

arg = new_arg

from pandas.tools.merge import concat
from pandas.tools.concat import concat

def _agg_1dim(name, how, subset=None):
"""
Expand Down Expand Up @@ -579,7 +579,7 @@ def _agg(arg, func):
return result, True

def _aggregate_multiple_funcs(self, arg, _level):
from pandas.tools.merge import concat
from pandas.tools.concat import concat

if self.axis != 0:
raise NotImplementedError("axis other than 0 is not supported")
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ def describe(self):
counts = self.value_counts(dropna=False)
freqs = counts / float(counts.sum())

from pandas.tools.merge import concat
from pandas.tools.concat import concat
result = concat([counts, freqs], axis=1)
result.columns = ['counts', 'freqs']
result.index.name = 'categories'
Expand Down
9 changes: 5 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4402,7 +4402,7 @@ def append(self, other, ignore_index=False, verify_integrity=False):
if (self.columns.get_indexer(other.columns) >= 0).all():
other = other.loc[:, self.columns]

from pandas.tools.merge import concat
from pandas.tools.concat import concat
if isinstance(other, (list, tuple)):
to_concat = [self] + other
else:
Expand Down Expand Up @@ -4532,7 +4532,8 @@ def join(self, other, on=None, how='left', lsuffix='', rsuffix='',

def _join_compat(self, other, on=None, how='left', lsuffix='', rsuffix='',
sort=False):
from pandas.tools.merge import merge, concat
from pandas.tools.merge import merge
from pandas.tools.concat import concat

if isinstance(other, Series):
if other.name is None:
Expand Down Expand Up @@ -4636,7 +4637,7 @@ def round(self, decimals=0, *args, **kwargs):
Series.round
"""
from pandas.tools.merge import concat
from pandas.tools.concat import concat

def _dict_round(df, decimals):
for col, vals in df.iteritems():
Expand Down Expand Up @@ -5306,7 +5307,7 @@ def isin(self, values):
"""
if isinstance(values, dict):
from collections import defaultdict
from pandas.tools.merge import concat
from pandas.tools.concat import concat
values = defaultdict(list, values)
return concat((self.iloc[:, [i]].isin(values[col])
for i, col in enumerate(self.columns)), axis=1)
Expand Down
12 changes: 6 additions & 6 deletions pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ def _wrap_applied_output(self, *args, **kwargs):
raise AbstractMethodError(self)

def _concat_objects(self, keys, values, not_indexed_same=False):
from pandas.tools.merge import concat
from pandas.tools.concat import concat

def reset_identity(values):
# reset the identities of the components
Expand Down Expand Up @@ -3507,7 +3507,7 @@ def first_non_None_value(values):
# still a series
# path added as of GH 5545
elif all_indexed_same:
from pandas.tools.merge import concat
from pandas.tools.concat import concat
return concat(values)

if not all_indexed_same:
Expand Down Expand Up @@ -3540,7 +3540,7 @@ def first_non_None_value(values):
else:
# GH5788 instead of stacking; concat gets the
# dtypes correct
from pandas.tools.merge import concat
from pandas.tools.concat import concat
result = concat(values, keys=key_index,
names=key_index.names,
axis=self.axis).unstack()
Expand Down Expand Up @@ -3588,7 +3588,7 @@ def first_non_None_value(values):
not_indexed_same=not_indexed_same)

def _transform_general(self, func, *args, **kwargs):
from pandas.tools.merge import concat
from pandas.tools.concat import concat

applied = []
obj = self._obj_with_exclusions
Expand Down Expand Up @@ -3980,7 +3980,7 @@ def _iterate_column_groupbys(self):
exclusions=self.exclusions)

def _apply_to_column_groupbys(self, func):
from pandas.tools.merge import concat
from pandas.tools.concat import concat
return concat(
(func(col_groupby) for _, col_groupby
in self._iterate_column_groupbys()),
Expand Down Expand Up @@ -4061,7 +4061,7 @@ def groupby_series(obj, col=None):
if isinstance(obj, Series):
results = groupby_series(obj)
else:
from pandas.tools.merge import concat
from pandas.tools.concat import concat
results = [groupby_series(obj[col], col) for col in obj.columns]
results = concat(results, axis=1)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ def join(self, other, how='left', lsuffix='', rsuffix=''):
-------
joined : Panel
"""
from pandas.tools.merge import concat
from pandas.tools.concat import concat

if isinstance(other, Panel):
join_major, join_minor = self._get_join_index(other, how)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ def get_dummies(data, prefix=None, prefix_sep='_', dummy_na=False,
--------
Series.str.get_dummies
"""
from pandas.tools.merge import concat
from pandas.tools.concat import concat
from itertools import cycle

if isinstance(data, DataFrame):
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ def append(self, to_append, ignore_index=False, verify_integrity=False):
"""
from pandas.tools.merge import concat
from pandas.tools.concat import concat

if isinstance(to_append, (list, tuple)):
to_concat = [self] + to_append
Expand Down
4 changes: 2 additions & 2 deletions pandas/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def __init__(self, series, buf=None, length=True, header=True, index=True,
self._chk_truncate()

def _chk_truncate(self):
from pandas.tools.merge import concat
from pandas.tools.concat import concat
max_rows = self.max_rows
truncate_v = max_rows and (len(self.series) > max_rows)
series = self.series
Expand Down Expand Up @@ -406,7 +406,7 @@ def _chk_truncate(self):
Checks whether the frame should be truncated. If so, slices
the frame up.
"""
from pandas.tools.merge import concat
from pandas.tools.concat import concat

# Column of which first element is used to determine width of a dot col
self.tr_size_col = -1
Expand Down
4 changes: 1 addition & 3 deletions pandas/io/gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import numpy as np

from distutils.version import StrictVersion
from pandas import compat
from pandas.core.api import DataFrame
from pandas.tools.merge import concat
from pandas import compat, DataFrame, concat
from pandas.core.common import PandasError
from pandas.compat import lzip, bytes_to_str

Expand Down
8 changes: 3 additions & 5 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@

import pandas as pd
from pandas import (Series, DataFrame, Panel, Panel4D, Index,
MultiIndex, Int64Index, isnull)
MultiIndex, Int64Index, isnull, concat,
SparseSeries, SparseDataFrame, PeriodIndex,
DatetimeIndex, TimedeltaIndex)
from pandas.core import config
from pandas.io.common import _stringify_path
from pandas.sparse.api import SparseSeries, SparseDataFrame
from pandas.sparse.array import BlockIndex, IntIndex
from pandas.tseries.api import PeriodIndex, DatetimeIndex
from pandas.tseries.tdi import TimedeltaIndex
from pandas.core.base import StringMixin
from pandas.formats.printing import adjoin, pprint_thing
from pandas.core.common import _asarray_tuplesafe, PerformanceWarning
Expand All @@ -42,7 +41,6 @@
_block2d_to_blocknd,
_factor_indexer, _block_shape)
from pandas.core.index import _ensure_index
from pandas.tools.merge import concat
from pandas import compat
from pandas.compat import u_safe as u, PY3, range, lrange, string_types, filter
from pandas.core.config import get_option
Expand Down
5 changes: 2 additions & 3 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
from numpy import nan

from pandas import (date_range, bdate_range, Timestamp,
isnull, Index, MultiIndex, DataFrame, Series)
isnull, Index, MultiIndex, DataFrame, Series,
concat, Panel)
from pandas.core.common import UnsupportedFunctionCall
from pandas.util.testing import (assert_panel_equal, assert_frame_equal,
assert_series_equal, assert_almost_equal,
assert_index_equal, assertRaisesRegexp)
from pandas.compat import (range, long, lrange, StringIO, lmap, lzip, map, zip,
builtins, OrderedDict, product as cart_product)
from pandas import compat
from pandas.core.panel import Panel
from pandas.tools.merge import concat
from collections import defaultdict
import pandas.core.common as com
import numpy as np
Expand Down
Loading

0 comments on commit ba34c51

Please sign in to comment.