diff --git a/pandas/core/arrays/base.py b/pandas/core/arrays/base.py index f842d1237cb14..eb2fef482ff17 100644 --- a/pandas/core/arrays/base.py +++ b/pandas/core/arrays/base.py @@ -5,16 +5,18 @@ This is an experimental API and subject to breaking changes without warning. """ -import numpy as np - import operator -from pandas.core.dtypes.generic import ABCSeries, ABCIndexClass -from pandas.errors import AbstractMethodError +import numpy as np + +from pandas.compat import PY3, set_function_name from pandas.compat.numpy import function as nv -from pandas.compat import set_function_name, PY3 -from pandas.core import ops +from pandas.errors import AbstractMethodError + from pandas.core.dtypes.common import is_list_like +from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries + +from pandas.core import ops _not_implemented_message = "{} does not implement {}." diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 276ef6426a51b..6dc3a960dc817 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -1,61 +1,46 @@ # pylint: disable=E1101,W0232 -import numpy as np -from warnings import warn import textwrap +from warnings import warn -from pandas import compat -from pandas.compat import u, lzip -from pandas._libs import lib, algos as libalgos +import numpy as np + +from pandas._libs import algos as libalgos, lib +import pandas.compat as compat +from pandas.compat import lzip, u +from pandas.compat.numpy import function as nv +from pandas.util._decorators import ( + Appender, Substitution, cache_readonly, deprecate_kwarg) +from pandas.util._validators import validate_bool_kwarg, validate_fillna_kwargs -from pandas.core.dtypes.generic import ( - ABCSeries, ABCIndexClass, ABCCategoricalIndex) -from pandas.core.dtypes.missing import isna, notna -from pandas.core.dtypes.inference import is_hashable from pandas.core.dtypes.cast import ( - maybe_infer_to_datetimelike, - coerce_indexer_dtype) -from pandas.core.dtypes.dtypes import CategoricalDtype + coerce_indexer_dtype, maybe_infer_to_datetimelike) from pandas.core.dtypes.common import ( - ensure_int64, - ensure_object, - ensure_platform_int, - is_extension_array_dtype, - is_dtype_equal, - is_datetimelike, - is_datetime64_dtype, - is_timedelta64_dtype, - is_categorical, - is_categorical_dtype, - is_float_dtype, - is_integer_dtype, - is_object_dtype, - is_list_like, is_sequence, - is_scalar, is_iterator, - is_dict_like) - -from pandas.core.algorithms import factorize, take_1d, unique1d, take + ensure_int64, ensure_object, ensure_platform_int, is_categorical, + is_categorical_dtype, is_datetime64_dtype, is_datetimelike, is_dict_like, + is_dtype_equal, is_extension_array_dtype, is_float_dtype, is_integer_dtype, + is_iterator, is_list_like, is_object_dtype, is_scalar, is_sequence, + is_timedelta64_dtype) +from pandas.core.dtypes.dtypes import CategoricalDtype +from pandas.core.dtypes.generic import ( + ABCCategoricalIndex, ABCIndexClass, ABCSeries) +from pandas.core.dtypes.inference import is_hashable +from pandas.core.dtypes.missing import isna, notna + from pandas.core.accessor import PandasDelegate, delegate_names -from pandas.core.base import (PandasObject, - NoNewAttributesMixin, _shared_docs) +import pandas.core.algorithms as algorithms +from pandas.core.algorithms import factorize, take, take_1d, unique1d +from pandas.core.base import NoNewAttributesMixin, PandasObject, _shared_docs import pandas.core.common as com +from pandas.core.config import get_option from pandas.core.missing import interpolate_2d -from pandas.compat.numpy import function as nv -from pandas.util._decorators import ( - Appender, cache_readonly, deprecate_kwarg, Substitution) - -import pandas.core.algorithms as algorithms - from pandas.core.sorting import nargsort from pandas.io.formats import console from pandas.io.formats.terminal import get_terminal_size -from pandas.util._validators import validate_bool_kwarg, validate_fillna_kwargs -from pandas.core.config import get_option from .base import ExtensionArray - _take_msg = textwrap.dedent("""\ Interpreting negative values in 'indexer' as missing values. In the future, this will change to meaning positional indices diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 631257b7a5264..4e784d9c89c5f 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -5,44 +5,33 @@ import numpy as np -from pandas._libs import lib, iNaT, NaT +from pandas._libs import NaT, iNaT, lib from pandas._libs.tslibs import timezones -from pandas._libs.tslibs.timedeltas import delta_to_nanoseconds, Timedelta -from pandas._libs.tslibs.timestamps import maybe_integer_op_deprecated from pandas._libs.tslibs.period import ( - Period, DIFFERENT_FREQ_INDEX, IncompatibleFrequency) - + DIFFERENT_FREQ_INDEX, IncompatibleFrequency, Period) +from pandas._libs.tslibs.timedeltas import Timedelta, delta_to_nanoseconds +from pandas._libs.tslibs.timestamps import maybe_integer_op_deprecated +import pandas.compat as compat from pandas.errors import ( AbstractMethodError, NullFrequencyError, PerformanceWarning) -from pandas import compat - -from pandas.tseries import frequencies -from pandas.tseries.offsets import Tick, DateOffset +from pandas.util._decorators import deprecate_kwarg from pandas.core.dtypes.common import ( - pandas_dtype, - needs_i8_conversion, - is_list_like, - is_offsetlike, - is_extension_array_dtype, - is_datetime64_dtype, - is_datetime64_any_dtype, - is_datetime64tz_dtype, - is_float_dtype, - is_integer_dtype, - is_bool_dtype, - is_period_dtype, - is_timedelta64_dtype, - is_object_dtype) -from pandas.core.dtypes.generic import ABCSeries, ABCDataFrame, ABCIndexClass + is_bool_dtype, is_datetime64_any_dtype, is_datetime64_dtype, + is_datetime64tz_dtype, is_extension_array_dtype, is_float_dtype, + is_integer_dtype, is_list_like, is_object_dtype, is_offsetlike, + is_period_dtype, is_timedelta64_dtype, needs_i8_conversion, pandas_dtype) from pandas.core.dtypes.dtypes import DatetimeTZDtype +from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries from pandas.core.dtypes.missing import isna -import pandas.core.common as com from pandas.core.algorithms import checked_add_with_arr, take, unique1d +import pandas.core.common as com + +from pandas.tseries import frequencies +from pandas.tseries.offsets import DateOffset, Tick from .base import ExtensionOpsMixin -from pandas.util._decorators import deprecate_kwarg def _make_comparison_op(cls, op): diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index c56e994e0ca2f..2187ff28844a0 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -6,35 +6,28 @@ from pytz import utc from pandas._libs import lib, tslib -from pandas._libs.tslib import Timestamp, NaT, iNaT +from pandas._libs.tslib import NaT, Timestamp, iNaT from pandas._libs.tslibs import ( - ccalendar, normalize_date, - conversion, fields, timezones, - resolution as libresolution) - -from pandas.util._decorators import cache_readonly, Appender + ccalendar, conversion, fields, normalize_date, resolution as libresolution, + timezones) +import pandas.compat as compat from pandas.errors import PerformanceWarning -from pandas import compat +from pandas.util._decorators import Appender, cache_readonly from pandas.core.dtypes.common import ( - _NS_DTYPE, - is_object_dtype, - is_int64_dtype, - is_datetime64tz_dtype, - is_datetime64_dtype) + _NS_DTYPE, is_datetime64_dtype, is_datetime64tz_dtype, is_int64_dtype, + is_object_dtype) from pandas.core.dtypes.dtypes import DatetimeTZDtype -from pandas.core.dtypes.missing import isna from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries +from pandas.core.dtypes.missing import isna -import pandas.core.common as com -from pandas.core.algorithms import checked_add_with_arr from pandas.core import ops - -from pandas.tseries.frequencies import to_offset, get_period_alias -from pandas.tseries.offsets import Tick, generate_range - +from pandas.core.algorithms import checked_add_with_arr from pandas.core.arrays import datetimelike as dtl +import pandas.core.common as com +from pandas.tseries.frequencies import get_period_alias, to_offset +from pandas.tseries.offsets import Tick, generate_range _midnight = time(0, 0) diff --git a/pandas/core/arrays/integer.py b/pandas/core/arrays/integer.py index 9e045a7785660..e9d51aaea4218 100644 --- a/pandas/core/arrays/integer.py +++ b/pandas/core/arrays/integer.py @@ -1,31 +1,27 @@ +import copy import sys import warnings -import copy -import numpy as np +import numpy as np from pandas._libs import lib +from pandas.compat import range, set_function_name, string_types, u from pandas.util._decorators import cache_readonly -from pandas.compat import u, range, string_types -from pandas.compat import set_function_name -from pandas.core import nanops +from pandas.core.dtypes.base import ExtensionDtype from pandas.core.dtypes.cast import astype_nansafe -from pandas.core.dtypes.generic import ABCSeries, ABCIndexClass from pandas.core.dtypes.common import ( - is_integer, is_scalar, is_float, - is_bool_dtype, - is_float_dtype, - is_integer_dtype, - is_object_dtype, - is_list_like) -from pandas.core.arrays import ExtensionArray, ExtensionOpsMixin -from pandas.core.dtypes.base import ExtensionDtype + is_bool_dtype, is_float, is_float_dtype, is_integer, is_integer_dtype, + is_list_like, is_object_dtype, is_scalar) from pandas.core.dtypes.dtypes import register_extension_dtype +from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries from pandas.core.dtypes.missing import isna, notna +from pandas.core import nanops +from pandas.core.arrays import ExtensionArray, ExtensionOpsMixin + from pandas.io.formats.printing import ( - format_object_summary, format_object_attrs, default_pprint) + default_pprint, format_object_attrs, format_object_summary) class _IntegerDtype(ExtensionDtype): diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 90118cd300a22..70be850481d85 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -1,31 +1,30 @@ +from operator import le, lt import textwrap -import numpy as np -from operator import le, lt +import numpy as np -from pandas._libs.interval import (Interval, IntervalMixin, - intervals_to_interval_bounds) +from pandas._libs.interval import ( + Interval, IntervalMixin, intervals_to_interval_bounds) from pandas.compat import add_metaclass from pandas.compat.numpy import function as nv -import pandas.core.common as com -from pandas.core.config import get_option +from pandas.util._decorators import Appender +from pandas.util._doctools import _WritableDoc + from pandas.core.dtypes.cast import maybe_convert_platform -from pandas.core.dtypes.common import (is_categorical_dtype, is_float_dtype, - is_integer_dtype, is_interval_dtype, - is_scalar, is_string_dtype, - is_datetime64_any_dtype, - is_timedelta64_dtype, is_interval, - pandas_dtype) +from pandas.core.dtypes.common import ( + is_categorical_dtype, is_datetime64_any_dtype, is_float_dtype, + is_integer_dtype, is_interval, is_interval_dtype, is_scalar, + is_string_dtype, is_timedelta64_dtype, pandas_dtype) from pandas.core.dtypes.dtypes import IntervalDtype -from pandas.core.dtypes.generic import (ABCDatetimeIndex, ABCPeriodIndex, - ABCSeries, ABCIntervalIndex, - ABCInterval) +from pandas.core.dtypes.generic import ( + ABCDatetimeIndex, ABCInterval, ABCIntervalIndex, ABCPeriodIndex, ABCSeries) from pandas.core.dtypes.missing import isna, notna + +import pandas.core.common as com +from pandas.core.config import get_option from pandas.core.indexes.base import Index, ensure_index -from pandas.util._decorators import Appender -from pandas.util._doctools import _WritableDoc -from . import ExtensionArray, Categorical +from . import Categorical, ExtensionArray _VALID_CLOSED = {'left', 'right', 'both', 'neither'} _interval_shared_docs = {} diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index d9989b1ac36c0..53629dca4d391 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -4,48 +4,35 @@ import numpy as np -from pandas import compat -from pandas.compat.numpy import function as nv from pandas._libs.tslib import NaT, iNaT -from pandas._libs.tslibs.period import ( - Period, IncompatibleFrequency, DIFFERENT_FREQ_INDEX, - get_period_field_arr, period_asfreq_arr, -) from pandas._libs.tslibs import period as libperiod -from pandas._libs.tslibs.timedeltas import delta_to_nanoseconds, Timedelta from pandas._libs.tslibs.fields import isleapyear_arr -from pandas.util._decorators import cache_readonly, Appender +from pandas._libs.tslibs.period import ( + DIFFERENT_FREQ_INDEX, IncompatibleFrequency, Period, get_period_field_arr, + period_asfreq_arr) +from pandas._libs.tslibs.timedeltas import Timedelta, delta_to_nanoseconds +import pandas.compat as compat +from pandas.compat.numpy import function as nv +from pandas.util._decorators import Appender, cache_readonly from pandas.util._validators import validate_fillna_kwargs -import pandas.core.algorithms as algos + from pandas.core.dtypes.common import ( - is_integer_dtype, is_float_dtype, is_period_dtype, - pandas_dtype, - is_datetime64_dtype, - is_categorical_dtype, - is_list_like, - is_array_like, - is_object_dtype, - is_string_dtype, - is_datetime_or_timedelta_dtype, - is_dtype_equal, - ensure_object, - _TD_DTYPE, -) + _TD_DTYPE, ensure_object, is_array_like, is_categorical_dtype, + is_datetime64_dtype, is_datetime_or_timedelta_dtype, is_dtype_equal, + is_float_dtype, is_integer_dtype, is_list_like, is_object_dtype, + is_period_dtype, is_string_dtype, pandas_dtype) from pandas.core.dtypes.dtypes import PeriodDtype -from pandas.core.dtypes.generic import ( - ABCSeries, ABCIndexClass, ABCPeriodIndex -) +from pandas.core.dtypes.generic import ABCIndexClass, ABCPeriodIndex, ABCSeries from pandas.core.dtypes.missing import isna, notna -from pandas.core.missing import pad_1d, backfill_1d +import pandas.core.algorithms as algos +from pandas.core.arrays import ExtensionArray, datetimelike as dtl import pandas.core.common as com +from pandas.core.missing import backfill_1d, pad_1d from pandas.tseries import frequencies from pandas.tseries.offsets import Tick -from pandas.core.arrays import ExtensionArray -from pandas.core.arrays import datetimelike as dtl - def _field_accessor(name, alias, docstring=None): def f(self): diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index cb630c9b66c20..38e28e8b77359 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -5,32 +5,25 @@ import numpy as np from pandas._libs import tslibs -from pandas._libs.tslibs import Timedelta, Timestamp, NaT, iNaT +from pandas._libs.tslibs import NaT, Timedelta, Timestamp, iNaT from pandas._libs.tslibs.fields import get_timedelta_field from pandas._libs.tslibs.timedeltas import ( array_to_timedelta64, parse_timedelta_unit) +import pandas.compat as compat from pandas.util._decorators import Appender -from pandas import compat - from pandas.core.dtypes.common import ( - _TD_DTYPE, - is_object_dtype, - is_string_dtype, - is_float_dtype, - is_integer_dtype, - is_timedelta64_dtype, - is_datetime64_dtype, - is_list_like, - ensure_int64) + _TD_DTYPE, ensure_int64, is_datetime64_dtype, is_float_dtype, + is_integer_dtype, is_list_like, is_object_dtype, is_string_dtype, + is_timedelta64_dtype) from pandas.core.dtypes.generic import ABCSeries, ABCTimedeltaIndex from pandas.core.dtypes.missing import isna -import pandas.core.common as com from pandas.core.algorithms import checked_add_with_arr +import pandas.core.common as com -from pandas.tseries.offsets import Tick from pandas.tseries.frequencies import to_offset +from pandas.tseries.offsets import Tick from . import datetimelike as dtl diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 1f2a1ee52159e..857bf18c5982b 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -1,76 +1,45 @@ # -*- coding: utf-8 -*- +from datetime import date, datetime, timedelta import functools -import warnings import inspect import re -from datetime import datetime, timedelta, date +import warnings import numpy as np -from pandas._libs import lib, tslib, tslibs, internals as libinternals -from pandas._libs.tslibs import conversion, Timedelta - -from pandas import compat +from pandas._libs import internals as libinternals, lib, tslib, tslibs +from pandas._libs.tslibs import Timedelta, conversion +import pandas.compat as compat from pandas.compat import range, zip - from pandas.util._validators import validate_bool_kwarg -from pandas.core.dtypes.dtypes import ( - ExtensionDtype, DatetimeTZDtype, - PandasExtensionDtype, - CategoricalDtype) -from pandas.core.dtypes.common import ( - _TD_DTYPE, _NS_DTYPE, - ensure_platform_int, - is_integer, - is_dtype_equal, - is_timedelta64_dtype, - is_datetime64_dtype, is_datetimetz, - is_categorical, is_categorical_dtype, - is_integer_dtype, - is_datetime64tz_dtype, - is_bool_dtype, - is_object_dtype, - is_float_dtype, - is_numeric_v_string_like, is_extension_type, - is_extension_array_dtype, - is_list_like, - is_re, - is_re_compilable, - is_sparse, - pandas_dtype) from pandas.core.dtypes.cast import ( - maybe_downcast_to_dtype, - maybe_upcast, - maybe_promote, - infer_dtype_from, - infer_dtype_from_scalar, - soft_convert_objects, - maybe_convert_objects, - astype_nansafe, - find_common_type, - maybe_infer_dtype_type) -from pandas.core.dtypes.missing import ( - isna, notna, array_equivalent, - _isna_compat, - is_null_datelike_scalar) + astype_nansafe, find_common_type, infer_dtype_from, + infer_dtype_from_scalar, maybe_convert_objects, maybe_downcast_to_dtype, + maybe_infer_dtype_type, maybe_promote, maybe_upcast, soft_convert_objects) +from pandas.core.dtypes.common import ( + _NS_DTYPE, _TD_DTYPE, ensure_platform_int, is_bool_dtype, is_categorical, + is_categorical_dtype, is_datetime64_dtype, is_datetime64tz_dtype, + is_datetimetz, is_dtype_equal, is_extension_array_dtype, is_extension_type, + is_float_dtype, is_integer, is_integer_dtype, is_list_like, + is_numeric_v_string_like, is_object_dtype, is_re, is_re_compilable, + is_sparse, is_timedelta64_dtype, pandas_dtype) import pandas.core.dtypes.concat as _concat +from pandas.core.dtypes.dtypes import ( + CategoricalDtype, DatetimeTZDtype, ExtensionDtype, PandasExtensionDtype) from pandas.core.dtypes.generic import ( - ABCSeries, - ABCDatetimeIndex, - ABCExtensionArray, - ABCIndexClass) + ABCDatetimeIndex, ABCExtensionArray, ABCIndexClass, ABCSeries) +from pandas.core.dtypes.missing import ( + _isna_compat, array_equivalent, is_null_datelike_scalar, isna, notna) -import pandas.core.common as com import pandas.core.algorithms as algos -import pandas.core.missing as missing -from pandas.core.base import PandasObject - from pandas.core.arrays import Categorical - +from pandas.core.base import PandasObject +import pandas.core.common as com from pandas.core.indexes.datetimes import DatetimeIndex from pandas.core.indexes.timedeltas import TimedeltaIndex from pandas.core.indexing import check_setitem_lengths +import pandas.core.missing as missing from pandas.io.formats.printing import pprint_thing diff --git a/pandas/core/internals/concat.py b/pandas/core/internals/concat.py index dfb7408384038..2fb533478b2f3 100644 --- a/pandas/core/internals/concat.py +++ b/pandas/core/internals/concat.py @@ -1,23 +1,19 @@ # -*- coding: utf-8 -*- # TODO: Needs a better name; too many modules are already called "concat" -import copy from collections import defaultdict +import copy import numpy as np -from pandas._libs import tslibs, internals as libinternals +from pandas._libs import internals as libinternals, tslibs from pandas.util._decorators import cache_readonly -from pandas.core.dtypes.missing import isna -from pandas.core.dtypes.common import ( - is_timedelta64_dtype, - is_datetime64_dtype, is_datetimetz, - is_categorical_dtype, - is_float_dtype, is_numeric_dtype, - is_sparse, - _get_dtype) from pandas.core.dtypes.cast import maybe_promote +from pandas.core.dtypes.common import ( + _get_dtype, is_categorical_dtype, is_datetime64_dtype, is_datetimetz, + is_float_dtype, is_numeric_dtype, is_sparse, is_timedelta64_dtype) import pandas.core.dtypes.concat as _concat +from pandas.core.dtypes.missing import isna import pandas.core.algorithms as algos diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index 0519c5e5abe33..c3762d9819153 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -7,42 +7,34 @@ import numpy as np -from pandas._libs import lib, internals as libinternals - +from pandas._libs import internals as libinternals, lib +from pandas.compat import map, range, zip from pandas.util._validators import validate_bool_kwarg -from pandas.compat import range, map, zip -from pandas.core.dtypes.common import ( - _NS_DTYPE, - is_datetimelike_v_numeric, - is_numeric_v_string_like, is_extension_type, - is_extension_array_dtype, - is_scalar) from pandas.core.dtypes.cast import ( - maybe_promote, - infer_dtype_from_scalar, - find_common_type, - maybe_convert_objects) -from pandas.core.dtypes.missing import isna + find_common_type, infer_dtype_from_scalar, maybe_convert_objects, + maybe_promote) +from pandas.core.dtypes.common import ( + _NS_DTYPE, is_datetimelike_v_numeric, is_extension_array_dtype, + is_extension_type, is_numeric_v_string_like, is_scalar) import pandas.core.dtypes.concat as _concat -from pandas.core.dtypes.generic import ABCSeries, ABCExtensionArray +from pandas.core.dtypes.generic import ABCExtensionArray, ABCSeries +from pandas.core.dtypes.missing import isna -from pandas.core.base import PandasObject import pandas.core.algorithms as algos from pandas.core.arrays.sparse import _maybe_to_sparse - +from pandas.core.base import PandasObject from pandas.core.index import Index, MultiIndex, ensure_index from pandas.core.indexing import maybe_convert_indices from pandas.io.formats.printing import pprint_thing from .blocks import ( - Block, DatetimeTZBlock, CategoricalBlock, ExtensionBlock, - _extend_blocks, _merge_blocks, _safe_reshape, - make_block, get_block_type) + Block, CategoricalBlock, DatetimeTZBlock, ExtensionBlock, _extend_blocks, + _merge_blocks, _safe_reshape, get_block_type, make_block) from .concat import ( # all for concatenate_block_managers - concatenate_join_units, is_uniform_join_units, - get_mgr_concatenation_plan, combine_concat_plans) + combine_concat_plans, concatenate_join_units, get_mgr_concatenation_plan, + is_uniform_join_units) # TODO: flexible with index=None and/or items=None diff --git a/pandas/core/sparse/api.py b/pandas/core/sparse/api.py index e3be241bcdd70..33e8b921905ba 100644 --- a/pandas/core/sparse/api.py +++ b/pandas/core/sparse/api.py @@ -1,5 +1,5 @@ # pylint: disable=W0611 # flake8: noqa from pandas.core.arrays.sparse import SparseArray, SparseDtype -from pandas.core.sparse.series import SparseSeries from pandas.core.sparse.frame import SparseDataFrame +from pandas.core.sparse.series import SparseSeries diff --git a/pandas/core/sparse/frame.py b/pandas/core/sparse/frame.py index ee7de49bc1bce..a25ffa2744cb7 100644 --- a/pandas/core/sparse/frame.py +++ b/pandas/core/sparse/frame.py @@ -3,32 +3,36 @@ with float64 data """ from __future__ import division -# pylint: disable=E1101,E1103,W0231,E0202 import warnings -from pandas.compat import lmap -from pandas import compat + import numpy as np -from pandas.core.dtypes.missing import isna, notna -from pandas.core.dtypes.cast import maybe_upcast, find_common_type +from pandas._libs.sparse import BlockIndex, get_blocks +import pandas.compat as compat +from pandas.compat import lmap +from pandas.compat.numpy import function as nv +from pandas.util._decorators import Appender + +from pandas.core.dtypes.cast import find_common_type, maybe_upcast from pandas.core.dtypes.common import ensure_platform_int, is_scipy_sparse +from pandas.core.dtypes.missing import isna, notna -from pandas.compat.numpy import function as nv -from pandas.core.index import Index, MultiIndex, ensure_index -from pandas.core.series import Series -from pandas.core.frame import DataFrame, extract_index, _prep_ndarray import pandas.core.algorithms as algos -from pandas.core.internals import (BlockManager, - create_block_manager_from_arrays) -import pandas.core.generic as generic from pandas.core.arrays.sparse import SparseArray, SparseDtype -from pandas.core.sparse.series import SparseSeries -from pandas._libs.sparse import BlockIndex, get_blocks -from pandas.util._decorators import Appender -import pandas.core.ops as ops import pandas.core.common as com +from pandas.core.frame import DataFrame, _prep_ndarray, extract_index +import pandas.core.generic as generic +from pandas.core.index import Index, MultiIndex, ensure_index import pandas.core.indexes.base as ibase +from pandas.core.internals import ( + BlockManager, create_block_manager_from_arrays) +import pandas.core.ops as ops +from pandas.core.series import Series +from pandas.core.sparse.series import SparseSeries + +# pylint: disable=E1101,E1103,W0231,E0202 + _shared_doc_kwargs = dict(klass='SparseDataFrame') diff --git a/pandas/core/sparse/scipy_sparse.py b/pandas/core/sparse/scipy_sparse.py index 748a52f484893..ab4fdeb05f8f1 100644 --- a/pandas/core/sparse/scipy_sparse.py +++ b/pandas/core/sparse/scipy_sparse.py @@ -3,10 +3,11 @@ Currently only includes SparseSeries.to_coo helpers. """ -from pandas.core.index import MultiIndex, Index -from pandas.core.series import Series from pandas.compat import OrderedDict, lmap +from pandas.core.index import Index, MultiIndex +from pandas.core.series import Series + def _check_is_partition(parts, whole): whole = set(whole) diff --git a/pandas/core/sparse/series.py b/pandas/core/sparse/series.py index ff32712f9056a..4ea4531c53c72 100644 --- a/pandas/core/sparse/series.py +++ b/pandas/core/sparse/series.py @@ -5,36 +5,30 @@ # pylint: disable=E1101,E1103,W0231 -import numpy as np import warnings -from pandas.core.dtypes.common import ( - is_scalar, -) -from pandas.core.dtypes.missing import isna, notna, is_integer +import numpy as np -from pandas import compat -from pandas.compat.numpy import function as nv -from pandas.core.index import Index -from pandas.core.series import Series -from pandas.core.dtypes.generic import ABCSeries, ABCSparseSeries -from pandas.core.internals import SingleBlockManager -from pandas.core import generic -import pandas.core.ops as ops import pandas._libs.index as libindex +import pandas._libs.sparse as splib +from pandas._libs.sparse import BlockIndex, IntIndex +import pandas.compat as compat +from pandas.compat.numpy import function as nv from pandas.util._decorators import Appender, Substitution -from pandas.core.arrays import ( - SparseArray, -) -from pandas.core.arrays.sparse import SparseAccessor -from pandas._libs.sparse import BlockIndex, IntIndex -import pandas._libs.sparse as splib +from pandas.core.dtypes.common import is_scalar +from pandas.core.dtypes.generic import ABCSeries, ABCSparseSeries +from pandas.core.dtypes.missing import is_integer, isna, notna +from pandas.core import generic +from pandas.core.arrays import SparseArray +from pandas.core.arrays.sparse import SparseAccessor +from pandas.core.index import Index +from pandas.core.internals import SingleBlockManager +import pandas.core.ops as ops +from pandas.core.series import Series from pandas.core.sparse.scipy_sparse import ( - _sparse_series_to_coo, - _coo_to_sparse_series) - + _coo_to_sparse_series, _sparse_series_to_coo) _shared_doc_kwargs = dict(axes='index', klass='SparseSeries', axes_single_arg="{0, 'index'}", diff --git a/pandas/core/tools/datetimes.py b/pandas/core/tools/datetimes.py index 0eb2ffeab28f1..2c6fdb3eaf03c 100644 --- a/pandas/core/tools/datetimes.py +++ b/pandas/core/tools/datetimes.py @@ -1,36 +1,24 @@ -from functools import partial -from datetime import datetime, time from collections import MutableMapping +from datetime import datetime, time +from functools import partial import numpy as np from pandas._libs import tslib, tslibs -from pandas._libs.tslibs.strptime import array_strptime -from pandas._libs.tslibs import parsing, conversion, Timestamp +from pandas._libs.tslibs import Timestamp, conversion, parsing from pandas._libs.tslibs.parsing import ( # noqa - parse_time_string, - DateParseError, - _format_is_iso, - _guess_datetime_format) + DateParseError, _format_is_iso, _guess_datetime_format, parse_time_string) +from pandas._libs.tslibs.strptime import array_strptime +from pandas.compat import zip from pandas.core.dtypes.common import ( - ensure_object, - is_datetime64_ns_dtype, - is_datetime64_dtype, - is_datetime64tz_dtype, - is_integer_dtype, - is_integer, - is_float, - is_list_like, - is_scalar, - is_numeric_dtype, - is_object_dtype) -from pandas.core.dtypes.generic import ( - ABCIndexClass, ABCSeries, - ABCDataFrame) + ensure_object, is_datetime64_dtype, is_datetime64_ns_dtype, + is_datetime64tz_dtype, is_float, is_integer, is_integer_dtype, + is_list_like, is_numeric_dtype, is_object_dtype, is_scalar) +from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries from pandas.core.dtypes.missing import notna + from pandas.core import algorithms -from pandas.compat import zip def _guess_datetime_format_for_array(arr, **kwargs): diff --git a/pandas/core/tools/numeric.py b/pandas/core/tools/numeric.py index 12699927141cb..1d4973de92b99 100644 --- a/pandas/core/tools/numeric.py +++ b/pandas/core/tools/numeric.py @@ -1,16 +1,15 @@ import numpy as np -import pandas as pd -from pandas.core.dtypes.common import ( - is_scalar, - is_numeric_dtype, - is_decimal, - is_datetime_or_timedelta_dtype, - is_number, - ensure_object) -from pandas.core.dtypes.generic import ABCSeries, ABCIndexClass -from pandas.core.dtypes.cast import maybe_downcast_to_dtype + from pandas._libs import lib +from pandas.core.dtypes.cast import maybe_downcast_to_dtype +from pandas.core.dtypes.common import ( + ensure_object, is_datetime_or_timedelta_dtype, is_decimal, is_number, + is_numeric_dtype, is_scalar) +from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries + +import pandas as pd + def to_numeric(arg, errors='raise', downcast=None): """ diff --git a/pandas/core/tools/timedeltas.py b/pandas/core/tools/timedeltas.py index db93820c6942f..2579efdbc65fe 100644 --- a/pandas/core/tools/timedeltas.py +++ b/pandas/core/tools/timedeltas.py @@ -3,14 +3,15 @@ """ import numpy as np -import pandas as pd + from pandas._libs import tslibs -from pandas._libs.tslibs.timedeltas import (convert_to_timedelta64, - parse_timedelta_unit) +from pandas._libs.tslibs.timedeltas import ( + convert_to_timedelta64, parse_timedelta_unit) from pandas.core.dtypes.common import is_list_like -from pandas.core.dtypes.generic import ABCSeries, ABCIndexClass +from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries +import pandas as pd from pandas.core.arrays.timedeltas import sequence_to_td64ns diff --git a/pandas/core/util/hashing.py b/pandas/core/util/hashing.py index 6a2cfd4d4a7b3..0e58b69465d3c 100644 --- a/pandas/core/util/hashing.py +++ b/pandas/core/util/hashing.py @@ -2,18 +2,17 @@ data hash pandas / numpy objects """ import itertools + import numpy as np + from pandas._libs import hashing, tslibs -from pandas.core.dtypes.generic import ( - ABCMultiIndex, - ABCIndexClass, - ABCSeries, - ABCDataFrame) + +from pandas.core.dtypes.cast import infer_dtype_from_scalar from pandas.core.dtypes.common import ( - is_categorical_dtype, is_list_like, is_extension_array_dtype) + is_categorical_dtype, is_extension_array_dtype, is_list_like) +from pandas.core.dtypes.generic import ( + ABCDataFrame, ABCIndexClass, ABCMultiIndex, ABCSeries) from pandas.core.dtypes.missing import isna -from pandas.core.dtypes.cast import infer_dtype_from_scalar - # 16 byte long hashing key _default_hash_key = '0123456789123456' diff --git a/setup.cfg b/setup.cfg index 5132e6c5f79cd..0214922585077 100644 --- a/setup.cfg +++ b/setup.cfg @@ -138,25 +138,6 @@ skip= pandas/core/indexes/accessors.py, pandas/core/indexes/period.py, pandas/core/indexes/frozen.py, - pandas/core/arrays/categorical.py, - pandas/core/arrays/integer.py, - pandas/core/arrays/interval.py, - pandas/core/arrays/timedeltas.py, - pandas/core/arrays/datetimelike.py, - pandas/core/arrays/datetimes.py, - pandas/core/arrays/base.py, - pandas/core/arrays/period.py, - pandas/core/util/hashing.py, - pandas/core/tools/numeric.py, - pandas/core/tools/timedeltas.py, - pandas/core/tools/datetimes.py, - pandas/core/internals/concat.py, - pandas/core/internals/managers.py, - pandas/core/internals/blocks.py, - pandas/core/sparse/api.py, - pandas/core/sparse/series.py, - pandas/core/sparse/frame.py, - pandas/core/sparse/scipy_sparse.py, pandas/tests/test_errors.py, pandas/tests/test_base.py, pandas/tests/test_register_accessor.py,