From 9019582c45d17035098941a666a8b6072c13a357 Mon Sep 17 00:00:00 2001 From: Charles David Date: Thu, 1 Nov 2018 02:10:12 +0100 Subject: [PATCH] style: fix import format at pandas/core/reshape (#23387) --- pandas/core/reshape/api.py | 6 ++-- pandas/core/reshape/concat.py | 20 +++++++------ pandas/core/reshape/melt.py | 17 +++++------ pandas/core/reshape/merge.py | 55 +++++++++++++--------------------- pandas/core/reshape/pivot.py | 27 ++++++++--------- pandas/core/reshape/reshape.py | 37 ++++++++++------------- pandas/core/reshape/tile.py | 26 +++++++--------- pandas/core/reshape/util.py | 3 +- setup.cfg | 8 ----- 9 files changed, 83 insertions(+), 116 deletions(-) diff --git a/pandas/core/reshape/api.py b/pandas/core/reshape/api.py index 7ac1c0cb52fe3..3c76eef809c7a 100644 --- a/pandas/core/reshape/api.py +++ b/pandas/core/reshape/api.py @@ -1,8 +1,8 @@ # flake8: noqa from pandas.core.reshape.concat import concat -from pandas.core.reshape.melt import melt, lreshape, wide_to_long +from pandas.core.reshape.melt import lreshape, melt, wide_to_long +from pandas.core.reshape.merge import merge, merge_asof, merge_ordered +from pandas.core.reshape.pivot import crosstab, pivot, pivot_table from pandas.core.reshape.reshape import get_dummies -from pandas.core.reshape.merge import merge, merge_ordered, merge_asof -from pandas.core.reshape.pivot import pivot_table, pivot, crosstab from pandas.core.reshape.tile import cut, qcut diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index aa380d95e5f36..9f8564541a936 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -3,17 +3,19 @@ """ import numpy as np -from pandas import compat, DataFrame, Series, Index, MultiIndex -from pandas.core.index import (_get_objs_combined_axis, - ensure_index, _get_consensus_names, - _all_indexes_same) -from pandas.core.arrays.categorical import (_factorize_from_iterable, - _factorize_from_iterables) -from pandas.core.internals import concatenate_block_managers + +import pandas.core.dtypes.concat as _concat + +from pandas import DataFrame, Index, MultiIndex, Series, compat from pandas.core import common as com -import pandas.core.indexes.base as ibase +from pandas.core.arrays.categorical import ( + _factorize_from_iterable, _factorize_from_iterables) from pandas.core.generic import NDFrame -import pandas.core.dtypes.concat as _concat +from pandas.core.index import ( + _all_indexes_same, _get_consensus_names, _get_objs_combined_axis, + ensure_index) +import pandas.core.indexes.base as ibase +from pandas.core.internals import concatenate_block_managers # --------------------------------------------------------------------- # Concatenate DataFrame objects diff --git a/pandas/core/reshape/melt.py b/pandas/core/reshape/melt.py index 26221143c0cdf..6596e055db1a8 100644 --- a/pandas/core/reshape/melt.py +++ b/pandas/core/reshape/melt.py @@ -1,21 +1,20 @@ # pylint: disable=E1101,E1103 # pylint: disable=W0703,W0622,W0613,W0201 +import re + import numpy as np -from pandas.core.dtypes.common import is_list_like -from pandas import compat -from pandas.core.arrays import Categorical +from pandas.util._decorators import Appender +from pandas.core.dtypes.common import is_extension_type, is_list_like from pandas.core.dtypes.generic import ABCMultiIndex +from pandas.core.dtypes.missing import notna +from pandas import compat +from pandas.core.arrays import Categorical from pandas.core.frame import _shared_docs -from pandas.util._decorators import Appender - -import re -from pandas.core.dtypes.missing import notna -from pandas.core.dtypes.common import is_extension_type -from pandas.core.tools.numeric import to_numeric from pandas.core.reshape.concat import concat +from pandas.core.tools.numeric import to_numeric @Appender(_shared_docs['melt'] % diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index 5d4a0c718499a..e09cf0a527ff9 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -3,49 +3,34 @@ """ import copy -import warnings import string +import warnings import numpy as np -from pandas.compat import range, lzip, zip, map, filter -import pandas.compat as compat -from pandas import (Categorical, DataFrame, - Index, MultiIndex, Timedelta, Series) -from pandas.core.arrays.categorical import _recode_for_categories -from pandas.core.frame import _merge_doc -from pandas.core.dtypes.common import ( - is_datetime64tz_dtype, - is_datetime64_dtype, - needs_i8_conversion, - is_int64_dtype, - is_array_like, - is_categorical_dtype, - is_integer_dtype, - is_float_dtype, - is_number, - is_numeric_dtype, - is_integer, - is_int_or_datetime_dtype, - is_dtype_equal, - is_bool, - is_bool_dtype, - is_list_like, - is_datetimelike, - ensure_int64, - ensure_float64, - ensure_object) -from pandas.core.dtypes.missing import na_value_for_dtype, isnull -from pandas.core.internals import (items_overlap_with_suffix, - concatenate_block_managers) +from pandas._libs import hashtable as libhashtable, join as libjoin, lib +import pandas.compat as compat +from pandas.compat import filter, lzip, map, range, zip +from pandas.errors import MergeError from pandas.util._decorators import Appender, Substitution -from pandas.core.sorting import is_int64_overflow_possible +from pandas.core.dtypes.common import ( + ensure_float64, ensure_int64, ensure_object, is_array_like, is_bool, + is_bool_dtype, is_categorical_dtype, is_datetime64_dtype, + is_datetime64tz_dtype, is_datetimelike, is_dtype_equal, is_float_dtype, + is_int64_dtype, is_int_or_datetime_dtype, is_integer, is_integer_dtype, + is_list_like, is_number, is_numeric_dtype, needs_i8_conversion) +from pandas.core.dtypes.missing import isnull, na_value_for_dtype + +from pandas import Categorical, DataFrame, Index, MultiIndex, Series, Timedelta import pandas.core.algorithms as algos -import pandas.core.sorting as sorting +from pandas.core.arrays.categorical import _recode_for_categories import pandas.core.common as com -from pandas._libs import hashtable as libhashtable, join as libjoin, lib -from pandas.errors import MergeError +from pandas.core.frame import _merge_doc +from pandas.core.internals import ( + concatenate_block_managers, items_overlap_with_suffix) +import pandas.core.sorting as sorting +from pandas.core.sorting import is_int64_overflow_possible @Substitution('\nleft : DataFrame') diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index 22e591e776a22..ec4cdffc56435 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -1,28 +1,25 @@ # pylint: disable=E1103 +import numpy as np +from pandas.compat import lrange, range, zip +from pandas.util._decorators import Appender, Substitution -from pandas.core.dtypes.common import ( - is_list_like, is_scalar, is_integer_dtype) -from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries from pandas.core.dtypes.cast import maybe_downcast_to_dtype +from pandas.core.dtypes.common import is_integer_dtype, is_list_like, is_scalar +from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries -from pandas.core.reshape.concat import concat -from pandas.core.series import Series -from pandas.core.groupby import Grouper -from pandas.core.reshape.util import cartesian_product -from pandas.core.index import Index, MultiIndex, _get_objs_combined_axis -from pandas.compat import range, lrange, zip from pandas import compat import pandas.core.common as com -from pandas.util._decorators import Appender, Substitution - from pandas.core.frame import _shared_docs -# Note: We need to make sure `frame` is imported before `pivot`, otherwise -# _shared_docs['pivot_table'] will not yet exist. TODO: Fix this dependency - -import numpy as np +from pandas.core.groupby import Grouper +from pandas.core.index import Index, MultiIndex, _get_objs_combined_axis +from pandas.core.reshape.concat import concat +from pandas.core.reshape.util import cartesian_product +from pandas.core.series import Series +# Note: We need to make sure `frame` is imported before `pivot`, otherwise +# _shared_docs['pivot_table'] will not yet exist. TODO: Fix this dependency @Substitution('\ndata : DataFrame') @Appender(_shared_docs['pivot_table'], indents=1) def pivot_table(data, values=None, index=None, columns=None, aggfunc='mean', diff --git a/pandas/core/reshape/reshape.py b/pandas/core/reshape/reshape.py index 03b77f0e787f0..d3b677a1df2a3 100644 --- a/pandas/core/reshape/reshape.py +++ b/pandas/core/reshape/reshape.py @@ -1,36 +1,31 @@ # pylint: disable=E1101,E1103 # pylint: disable=W0703,W0622,W0613,W0201 -from pandas.compat import range, text_type, zip, u, PY2 -from pandas import compat from functools import partial import itertools import numpy as np -from pandas.core.dtypes.common import ( - ensure_platform_int, - is_list_like, is_bool_dtype, - is_extension_array_dtype, - needs_i8_conversion, is_sparse, is_object_dtype) -from pandas.core.dtypes.cast import maybe_promote -from pandas.core.dtypes.missing import notna - -from pandas.core.series import Series -from pandas.core.frame import DataFrame - -from pandas.core.sparse.api import SparseDataFrame, SparseSeries -from pandas.core.arrays import SparseArray +from pandas._libs import algos as _algos, reshape as _reshape from pandas._libs.sparse import IntIndex +from pandas.compat import PY2, range, text_type, u, zip -from pandas.core.arrays import Categorical -from pandas.core.arrays.categorical import _factorize_from_iterable -from pandas.core.sorting import (get_group_index, get_compressed_ids, - compress_group_index, decons_obs_group_ids) +from pandas.core.dtypes.cast import maybe_promote +from pandas.core.dtypes.common import ( + ensure_platform_int, is_bool_dtype, is_extension_array_dtype, is_list_like, + is_object_dtype, is_sparse, needs_i8_conversion) +from pandas.core.dtypes.missing import notna +from pandas import compat import pandas.core.algorithms as algos -from pandas._libs import algos as _algos, reshape as _reshape - +from pandas.core.arrays import Categorical, SparseArray +from pandas.core.arrays.categorical import _factorize_from_iterable +from pandas.core.frame import DataFrame from pandas.core.index import Index, MultiIndex +from pandas.core.series import Series +from pandas.core.sorting import ( + compress_group_index, decons_obs_group_ids, get_compressed_ids, + get_group_index) +from pandas.core.sparse.api import SparseDataFrame, SparseSeries class _Unstacker(object): diff --git a/pandas/core/reshape/tile.py b/pandas/core/reshape/tile.py index 031c94c06d3c8..4a863372eea13 100644 --- a/pandas/core/reshape/tile.py +++ b/pandas/core/reshape/tile.py @@ -3,25 +3,21 @@ """ from functools import partial -from pandas.core.dtypes.missing import isna +import numpy as np + +from pandas._libs.lib import infer_dtype + from pandas.core.dtypes.common import ( - is_integer, - is_scalar, - is_categorical_dtype, - is_datetime64_dtype, - is_timedelta64_dtype, - is_datetime64tz_dtype, - is_datetime_or_timedelta_dtype, - ensure_int64) + ensure_int64, is_categorical_dtype, is_datetime64_dtype, + is_datetime64tz_dtype, is_datetime_or_timedelta_dtype, is_integer, + is_scalar, is_timedelta64_dtype) +from pandas.core.dtypes.missing import isna +from pandas import ( + Categorical, Index, Interval, IntervalIndex, Series, Timedelta, Timestamp, + to_datetime, to_timedelta) import pandas.core.algorithms as algos import pandas.core.nanops as nanops -from pandas._libs.lib import infer_dtype -from pandas import (to_timedelta, to_datetime, - Categorical, Timestamp, Timedelta, - Series, Index, Interval, IntervalIndex) - -import numpy as np def cut(x, bins, right=True, labels=None, retbins=False, precision=3, diff --git a/pandas/core/reshape/util.py b/pandas/core/reshape/util.py index 1c2033d90cd8a..07f7272398777 100644 --- a/pandas/core/reshape/util.py +++ b/pandas/core/reshape/util.py @@ -1,8 +1,9 @@ import numpy as np +from pandas.compat import reduce + from pandas.core.dtypes.common import is_list_like -from pandas.compat import reduce from pandas.core import common as com diff --git a/setup.cfg b/setup.cfg index 717705ca028c9..e0f1ea6fe3ac9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -152,14 +152,6 @@ skip= pandas/core/internals/concat.py, pandas/core/internals/managers.py, pandas/core/internals/blocks.py, - pandas/core/reshape/concat.py, - pandas/core/reshape/tile.py, - pandas/core/reshape/melt.py, - pandas/core/reshape/api.py, - pandas/core/reshape/util.py, - pandas/core/reshape/merge.py, - pandas/core/reshape/reshape.py, - pandas/core/reshape/pivot.py, pandas/core/sparse/api.py, pandas/core/sparse/series.py, pandas/core/sparse/frame.py,