Skip to content
Merged
2 changes: 1 addition & 1 deletion pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import pandas.core.config_init

from pandas.core.api import *
from pandas.core.sparse.api import *
from pandas.core.arrays.sparse.api import *
from pandas.tseries.api import *
from pandas.core.computation.api import *
from pandas.core.reshape.api import *
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/parsers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ from pandas.core.dtypes.common import (
is_bool_dtype, is_object_dtype,
is_datetime64_dtype,
pandas_dtype)
from pandas.core.arrays import Categorical
from pandas.core.arrays.categorical import Categorical
from pandas.core.dtypes.concat import union_categoricals
import pandas.io.common as icom

Expand Down
3 changes: 2 additions & 1 deletion pandas/compat/numpy/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"""

from numpy import ndarray
from pandas.util._validators import (validate_args, validate_kwargs,
from pandas.util._validators import (validate_args,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason you are changing unrelated things? (even formatting)

validate_kwargs,
validate_args_and_kwargs)
from pandas.errors import UnsupportedFunctionCall
from pandas.core.dtypes.common import is_integer, is_bool
Expand Down
23 changes: 18 additions & 5 deletions pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ def load_reduce(self):
# If classes are moved, provide compat here.
_class_locations_map = {

# 23123, fix sparse mapping
('pandas.core.sparse.array', 'SparseArray'):
('pandas.core.arrays.sparse.series', 'SparseArray'),
('pandas.core.sparse.series', 'SparseSeries'):
('pandas.core.arrays.sparse.series', 'SparseSeries'),
('pandas.core.sparse.frame', 'SparseDataFrame'):
('pandas.core.arrays.sparse.frame', 'SparseDataFrame'),

# 15477
('pandas.core.base', 'FrozenNDArray'):
('pandas.core.indexes.frozen', 'FrozenNDArray'),
Expand All @@ -67,7 +75,7 @@ def load_reduce(self):
('pandas.core.series', 'TimeSeries'):
('pandas.core.series', 'Series'),
('pandas.sparse.series', 'SparseTimeSeries'):
('pandas.core.sparse.series', 'SparseSeries'),
('pandas.core.arrays.sparse.series', 'SparseSeries'),

# 12588, extensions moving
('pandas._sparse', 'BlockIndex'):
Expand All @@ -88,11 +96,11 @@ def load_reduce(self):

# 15998 top-level dirs moving
('pandas.sparse.array', 'SparseArray'):
('pandas.core.sparse.array', 'SparseArray'),
('pandas.core.arrays.sparse.array', 'SparseArray'),
('pandas.sparse.series', 'SparseSeries'):
('pandas.core.sparse.series', 'SparseSeries'),
('pandas.core.arrays.sparse.series', 'SparseSeries'),
('pandas.sparse.frame', 'SparseDataFrame'):
('pandas.core.sparse.frame', 'SparseDataFrame'),
('pandas.core.arrays.sparse.frame', 'SparseDataFrame'),
('pandas.indexes.base', '_new_Index'):
('pandas.core.indexes.base', '_new_Index'),
('pandas.indexes.base', 'Index'):
Expand All @@ -112,7 +120,7 @@ def load_reduce(self):

# 19269, arrays moving
('pandas.core.categorical', 'Categorical'):
('pandas.core.arrays', 'Categorical'),
('pandas.core.arrays.categorical', 'Categorical'),

# 19939, add timedeltaindex, float64index compat from 15998 move
('pandas.tseries.tdi', 'TimedeltaIndex'):
Expand All @@ -130,8 +138,13 @@ class Unpickler(pkl._Unpickler):

def find_class(self, module, name):
# override superclass
print(module)
print(name)
key = (module, name)
module, name = _class_locations_map.get(key, key)
print(module)
print(name)
print("---")
return super(Unpickler, self).find_class(module, name)

else:
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from pandas.core.algorithms import factorize, unique, value_counts
from pandas.core.dtypes.missing import isna, isnull, notna, notnull
from pandas.core.arrays import Categorical
from pandas.core.arrays.categorical import Categorical
from pandas.core.groupby import Grouper
from pandas.io.formats.format import set_eng_float_format
from pandas.core.index import (Index, CategoricalIndex, Int64Index,
Expand Down
10 changes: 0 additions & 10 deletions pandas/core/arrays/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
from .base import (ExtensionArray, # noqa
ExtensionOpsMixin,
ExtensionScalarOpsMixin)
from .categorical import Categorical # noqa
from .datetimes import DatetimeArrayMixin # noqa
from .interval import IntervalArray # noqa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a nice pattern, pls restore this

from .period import PeriodArrayMixin # noqa
from .timedeltas import TimedeltaArrayMixin # noqa
from .integer import ( # noqa
IntegerArray, integer_array)
2 changes: 1 addition & 1 deletion pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ def __rsub__(self, other):
# we need to wrap in DatetimeArray/Index and flip the operation
if not isinstance(other, DatetimeLikeArrayMixin):
# Avoid down-casting DatetimeIndex
from pandas.core.arrays import DatetimeArrayMixin
from pandas.core.arrays.datetimes import DatetimeArrayMixin
other = DatetimeArrayMixin(other)
return other - self
elif (is_datetime64_any_dtype(self) and hasattr(other, 'dtype') and
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from pandas.tseries.frequencies import to_offset, get_period_alias
from pandas.tseries.offsets import Tick, generate_range

from pandas.core.arrays import datetimelike as dtl
import pandas.core.arrays.datetimelike as dtl


_midnight = time(0, 0)
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/arrays/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
is_integer_dtype,
is_object_dtype,
is_list_like)
from pandas.core.arrays import ExtensionArray, ExtensionOpsMixin
from pandas.core.arrays.base import (ExtensionArray,
ExtensionOpsMixin)
from pandas.core.dtypes.base import ExtensionDtype
from pandas.core.dtypes.dtypes import register_extension_dtype
from pandas.core.dtypes.missing import isna, notna
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
from pandas.util._decorators import Appender
from pandas.util._doctools import _WritableDoc

from . import ExtensionArray, Categorical
from pandas.core.arrays.base import ExtensionArray
from pandas.core.arrays.categorical import Categorical

_VALID_CLOSED = {'left', 'right', 'both', 'neither'}
_interval_shared_docs = {}
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from pandas.tseries import frequencies
from pandas.tseries.offsets import Tick, DateOffset

from pandas.core.arrays import datetimelike as dtl
import pandas.core.arrays.datetimelike as dtl
from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin


Expand Down
6 changes: 6 additions & 0 deletions pandas/core/arrays/sparse/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# pylint: disable=W0611
# flake8: noqa
from pandas.core.arrays.sparse.array import SparseArray
from pandas.core.arrays.sparse.series import SparseSeries
from pandas.core.arrays.sparse.frame import SparseDataFrame
from pandas.core.arrays.sparse.dtype import SparseDtype
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import pandas.core.algorithms as algos
import pandas.io.formats.printing as printing

from pandas.core.sparse.dtype import SparseDtype
from pandas.core.arrays.sparse.dtype import SparseDtype


_sparray_doc_kwargs = dict(klass='SparseArray')
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from pandas.core.internals import (BlockManager,
create_block_manager_from_arrays)
import pandas.core.generic as generic
from pandas.core.sparse.series import SparseSeries, SparseArray
from pandas.core.sparse.dtype import SparseDtype
from pandas.core.arrays.sparse.series import SparseSeries, SparseArray
from pandas.core.arrays.sparse.dtype import SparseDtype
from pandas._libs.sparse import BlockIndex, get_blocks
from pandas.util._decorators import Appender
import pandas.core.ops as ops
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""
Interaction with scipy.sparse matrices.

Currently only includes SparseSeries.to_coo helpers.
"""
from pandas.core.index import MultiIndex, Index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import pandas._libs.index as libindex
from pandas.util._decorators import Appender, Substitution

from pandas.core.sparse.array import (
from pandas.core.arrays.sparse.array import (
SparseArray,
)
from pandas._libs.sparse import BlockIndex, IntIndex
import pandas._libs.sparse as splib

from pandas.core.sparse.scipy_sparse import (
from pandas.core.arrays.sparse.scipy_sparse import (
_sparse_series_to_coo,
_coo_to_sparse_series)

Expand Down Expand Up @@ -205,7 +205,7 @@ def _constructor(self):

@property
def _constructor_expanddim(self):
from pandas.core.sparse.api import SparseDataFrame
from pandas.core.arrays.sparse.api import SparseDataFrame
return SparseDataFrame

@property
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def _add_delta(self, delta):

def _add_datelike(self, other):
# adding a timedeltaindex to a datetimelike
from pandas.core.arrays import DatetimeArrayMixin
from pandas.core.arrays.datetimes import DatetimeArrayMixin
if isinstance(other, (DatetimeArrayMixin, np.ndarray)):
# if other is an ndarray, we assume it is datetime64-dtype
# defer to implementation in DatetimeIndex
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
warnings.warn("'pandas.core' is private. Use 'pandas.Categorical'",
FutureWarning, stacklevel=2)

from pandas.core.arrays import Categorical # noqa
from pandas.core.arrays.categorical import Categorical # noqa
from pandas.core.dtypes.dtypes import CategoricalDtype # noqa
6 changes: 2 additions & 4 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" common type operations """

import numpy as np
from pandas.compat import (string_types, text_type, binary_type,
PY3, PY36)
Expand All @@ -12,7 +11,6 @@
PeriodDtype, IntervalDtype,
PandasExtensionDtype, ExtensionDtype,
_pandas_registry)
from pandas.core.sparse.dtype import SparseDtype
from pandas.core.dtypes.generic import (
ABCCategorical, ABCPeriodIndex, ABCDatetimeIndex, ABCSeries,
ABCSparseArray, ABCSparseSeries, ABCCategoricalIndex, ABCIndexClass,
Expand All @@ -22,7 +20,7 @@
is_dict_like, is_scalar, is_string_like, is_list_like, is_number,
is_file_like, is_re, is_re_compilable, is_sequence, is_nested_list_like,
is_named_tuple, is_array_like, is_decimal, is_complex, is_interval)

from pandas.core.arrays.sparse.dtype import SparseDtype

_POSSIBLY_CAST_DTYPES = {np.dtype(t).name
for t in ['O', 'int8', 'uint8', 'int16', 'uint16',
Expand Down Expand Up @@ -181,7 +179,7 @@ def is_sparse(arr):
>>> is_sparse(bsr_matrix([1, 2, 3]))
False
"""
from pandas.core.sparse.dtype import SparseDtype
from pandas.core.arrays.sparse.dtype import SparseDtype

dtype = getattr(arr, 'dtype', arr)
return isinstance(dtype, SparseDtype)
Expand Down
12 changes: 6 additions & 6 deletions pandas/core/dtypes/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ def _get_series_result_type(result, objs=None):
if isinstance(result, dict):
# concat Series with axis 1
if all(is_sparse(c) for c in compat.itervalues(result)):
from pandas.core.sparse.api import SparseDataFrame
from pandas.core.arrays.sparse.api import SparseDataFrame
return SparseDataFrame
else:
from pandas.core.frame import DataFrame
return DataFrame

# otherwise it is a SingleBlockManager (axis = 0)
if result._block.is_sparse:
from pandas.core.sparse.api import SparseSeries
from pandas.core.arrays.sparse.api import SparseSeries
return SparseSeries
else:
return objs[0]._constructor
Expand All @@ -100,7 +100,7 @@ def _get_frame_result_type(result, objs):
if (result.blocks and (
all(is_sparse(b) for b in result.blocks) or
all(isinstance(obj, ABCSparseDataFrame) for obj in objs))):
from pandas.core.sparse.api import SparseDataFrame
from pandas.core.arrays.sparse.api import SparseDataFrame
return SparseDataFrame
else:
return next(obj for obj in objs if not isinstance(obj,
Expand All @@ -123,7 +123,7 @@ def _get_sliced_frame_result_type(data, obj):
Series or SparseSeries
"""
if is_sparse(data):
from pandas.core.sparse.api import SparseSeries
from pandas.core.arrays.sparse.api import SparseSeries
return SparseSeries
return obj._constructor_sliced

Expand Down Expand Up @@ -523,7 +523,7 @@ def _concat_index_asobject(to_concat, name=None):
PeriodIndex are converted to object dtype before concatenation
"""
from pandas import Index
from pandas.core.arrays import ExtensionArray
from pandas.core.arrays.base import ExtensionArray

klasses = (ABCDatetimeIndex, ABCTimedeltaIndex, ABCPeriodIndex,
ExtensionArray)
Expand Down Expand Up @@ -556,7 +556,7 @@ def _concat_sparse(to_concat, axis=0, typs=None):
a single array, preserving the combined dtypes
"""

from pandas.core.sparse.array import SparseArray
from pandas.core.arrays.sparse.array import SparseArray

fill_values = [x.fill_value for x in to_concat
if isinstance(x, SparseArray)]
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ def construct_array_type(cls):
-------
type
"""
from pandas.core.arrays import IntervalArray
from pandas.core.arrays.interval import IntervalArray
return IntervalArray

@classmethod
Expand Down
7 changes: 4 additions & 3 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
from pandas.core import nanops
from pandas.core import ops
from pandas.core.accessor import CachedAccessor
from pandas.core.arrays import Categorical, ExtensionArray
from pandas.core.arrays.categorical import Categorical
from pandas.core.arrays.base import ExtensionArray
from pandas.core.config import get_option
from pandas.core.generic import NDFrame, _shared_docs
from pandas.core.index import (Index, MultiIndex, ensure_index,
Expand Down Expand Up @@ -1761,9 +1762,9 @@ def to_sparse(self, fill_value=None, kind='block'):
1 1.0 NaN
2 NaN 1.0
>>> type(sdf)
<class 'pandas.core.sparse.frame.SparseDataFrame'>
<class 'pandas.core.arrays.sparse.frame.SparseDataFrame'>
"""
from pandas.core.sparse.frame import SparseDataFrame
from pandas.core.arrays.sparse.frame import SparseDataFrame
return SparseDataFrame(self._series, index=self.index,
columns=self.columns, default_kind=kind,
default_fill_value=fill_value)
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/groupby/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from pandas.compat import zip, callable

from pandas.core.dtypes.generic import ABCSeries
from pandas.core.arrays import ExtensionArray, Categorical
from pandas.core.arrays.base import ExtensionArray
from pandas.core.arrays.categorical import Categorical
from pandas.core.index import (
Index, MultiIndex, CategoricalIndex)
from pandas.core.dtypes.common import (
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pandas import compat

from pandas.core.accessor import CachedAccessor
from pandas.core.arrays import ExtensionArray
from pandas.core.arrays.base import ExtensionArray
from pandas.core.dtypes.generic import (
ABCSeries, ABCDataFrame,
ABCMultiIndex,
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import pandas.core.dtypes.concat as _concat
from pandas.core.arrays.datetimes import DatetimeArrayMixin, _to_m8
from pandas.core.arrays import datetimelike as dtl
import pandas.core.arrays.datetimelike as dtl

from pandas.core.indexes.base import Index, _index_shared_docs
from pandas.core.indexes.numeric import Int64Index
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,7 @@ def _get_labels_for_sorting(self):
for sorting, where we need to disambiguate that -1 is not
a valid valid
"""
from pandas.core.arrays import Categorical
from pandas.core.arrays.categorical import Categorical

def cats(label):
return np.arange(np.array(label).max() + 1 if len(label) else 0,
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from pandas._libs.tslibs import resolution, period

from pandas.core.algorithms import unique1d
from pandas.core.arrays import datetimelike as dtl
import pandas.core.arrays.datetimelike as dtl
from pandas.core.arrays.period import PeriodArrayMixin, dt64arr_to_periodarr
from pandas.core.base import _shared_docs
from pandas.core.indexes.base import _index_shared_docs, ensure_index
Expand Down
Loading