Skip to content

DEPR: pandas.core.index #30193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 14, 2019
1 change: 1 addition & 0 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4751,6 +4751,7 @@ See the documentation for `pyarrow <https://arrow.apache.org/docs/python/>`__ an
Write to a parquet file.

.. ipython:: python
:okwarning:

df.to_parquet('example_pa.parquet', engine='pyarrow')
df.to_parquet('example_fp.parquet', engine='fastparquet')
Expand Down
4 changes: 2 additions & 2 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for mor
Other API changes
^^^^^^^^^^^^^^^^^

- Bumpded the minimum supported version of ``s3fs`` from 0.0.8 to 0.3.0 (:issue:`28616`)
- Bumped the minimum supported version of ``s3fs`` from 0.0.8 to 0.3.0 (:issue:`28616`)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you update the section that has our min supported version (in the whatsnew) (don't really need this issue line in that case)

- :class:`pandas.core.groupby.GroupBy.transform` now raises on invalid operation names (:issue:`27489`)
- :meth:`pandas.api.types.infer_dtype` will now return "integer-na" for integer and ``np.nan`` mix (:issue:`27283`)
- :meth:`MultiIndex.from_arrays` will no longer infer names from arrays if ``names=None`` is explicitly provided (:issue:`27292`)
Expand Down Expand Up @@ -490,7 +490,7 @@ Deprecations
- :func:`eval` keyword argument "truediv" is deprecated and will be removed in a future version (:issue:`29812`)
- :meth:`Categorical.take_nd` is deprecated, use :meth:`Categorical.take` instead (:issue:`27745`)
- The parameter ``numeric_only`` of :meth:`Categorical.min` and :meth:`Categorical.max` is deprecated and replaced with ``skipna`` (:issue:`25303`)
-
- ``pandas.core.index`` has been deprecated and will be removed in a future version, the public classes are available in the top-level namespace (:issue:`19711`)

.. _whatsnew_1000.prior_deprecations:

Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/internals.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ cdef class BlockPlacement:
return self._as_array

def isin(self, arr):
from pandas.core.index import Int64Index
from pandas.core.indexes.api import Int64Index
return Int64Index(self.as_array, copy=False).isin(arr)

@property
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def astype_str(arr: ndarray, skipna: bool=False) -> ndarray[object]:
@cython.boundscheck(False)
def clean_index_list(obj: list):
"""
Utility used in ``pandas.core.index.ensure_index``.
Utility used in ``pandas.core.indexes.api.ensure_index``.
"""
cdef:
Py_ssize_t i, n = len(obj)
Expand Down
14 changes: 7 additions & 7 deletions pandas/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import numpy as np

from pandas._libs import NaT, Period, Timedelta, Timestamp
from pandas._libs.missing import NA

from pandas.core.dtypes.dtypes import (
CategoricalDtype,
DatetimeTZDtype,
Expand All @@ -26,24 +29,23 @@
from pandas.core.arrays.string_ import StringDtype
from pandas.core.construction import array
from pandas.core.groupby import Grouper, NamedAgg
from pandas.core.index import (
from pandas.core.indexes.api import (
CategoricalIndex,
DatetimeIndex,
Float64Index,
Index,
Int64Index,
IntervalIndex,
MultiIndex,
NaT,
PeriodIndex,
RangeIndex,
TimedeltaIndex,
UInt64Index,
)
from pandas.core.indexes.datetimes import Timestamp, bdate_range, date_range
from pandas.core.indexes.datetimes import bdate_range, date_range
from pandas.core.indexes.interval import Interval, interval_range
from pandas.core.indexes.period import Period, period_range
from pandas.core.indexes.timedeltas import Timedelta, timedelta_range
from pandas.core.indexes.period import period_range
from pandas.core.indexes.timedeltas import timedelta_range
from pandas.core.indexing import IndexSlice
from pandas.core.series import Series
from pandas.core.tools.datetimes import to_datetime
Expand All @@ -55,5 +57,3 @@

# DataFrame needs to be imported after NamedAgg to avoid a circular import
from pandas.core.frame import DataFrame # isort:skip

from pandas._libs.missing import NA
2 changes: 1 addition & 1 deletion pandas/core/arrays/sparse/scipy_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
from collections import OrderedDict

from pandas.core.index import Index, MultiIndex
from pandas.core.indexes.api import Index, MultiIndex
from pandas.core.series import Series


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

if TYPE_CHECKING:
from pandas.core.series import Series # noqa: F401
from pandas.core.index import Index # noqa: F401
from pandas.core.indexes.api import Index # noqa: F401


def array(
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin as DatetimeLikeArray
from pandas.core.arrays.sparse import SparseFrameAccessor
from pandas.core.generic import NDFrame, _shared_docs
from pandas.core.index import Index, ensure_index, ensure_index_from_sequences
from pandas.core.indexes import base as ibase
from pandas.core.indexes.api import Index, ensure_index, ensure_index_from_sequences
from pandas.core.indexes.datetimes import DatetimeIndex
from pandas.core.indexes.multi import maybe_droplevels
from pandas.core.indexes.period import PeriodIndex
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
from pandas.core.base import PandasObject, SelectionMixin
import pandas.core.common as com
from pandas.core.construction import create_series_with_explicit_dtype
from pandas.core.index import (
from pandas.core.indexes.api import (
Index,
InvalidIndexError,
MultiIndex,
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class providing the base-class of operations.
from pandas.core.frame import DataFrame
from pandas.core.generic import NDFrame
from pandas.core.groupby import base, ops
from pandas.core.index import CategoricalIndex, Index, MultiIndex
from pandas.core.indexes.api import CategoricalIndex, Index, MultiIndex
from pandas.core.series import Series
from pandas.core.sorting import get_group_index_sorter

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/groupby/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pandas.core.frame import DataFrame
from pandas.core.groupby import ops
from pandas.core.groupby.categorical import recode_for_groupby, recode_from_groupby
from pandas.core.index import CategoricalIndex, Index, MultiIndex
from pandas.core.indexes.api import CategoricalIndex, Index, MultiIndex
from pandas.core.series import Series

from pandas.io.formats.printing import pprint_thing
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/groupby/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from pandas.core.frame import DataFrame
from pandas.core.generic import NDFrame
from pandas.core.groupby import base, grouper
from pandas.core.index import Index, MultiIndex, ensure_index
from pandas.core.indexes.api import Index, MultiIndex, ensure_index
from pandas.core.series import Series
from pandas.core.sorting import (
compress_group_index,
Expand Down
8 changes: 8 additions & 0 deletions pandas/core/index.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

from pandas.core.indexes.api import ( # noqa:F401
CategoricalIndex,
DatetimeIndex,
Expand All @@ -19,3 +21,9 @@
get_objs_combined_axis,
)
from pandas.core.indexes.multi import _sparsify # noqa:F401

warnings.warn(
"pandas.core.index is deprecated and will be removed in a future version. "
"Use pandas.core.indexes.api instead.",
Copy link
Member

Choose a reason for hiding this comment

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

Can you update this with the same as what you put in the whatsnew? (that is is available from the top-level namespace)

FutureWarning,
Copy link
Member

Choose a reason for hiding this comment

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

Let's start with a DeprecationWarning?

Copy link
Contributor

Choose a reason for hiding this comment

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

this has been around forever
let’s just be loud about it (and it had been deprecation via documentation. forever)

Copy link
Member

Choose a reason for hiding this comment

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

OK, opened an issue about it at fastparquet: dask/fastparquet#470

)
2 changes: 0 additions & 2 deletions pandas/core/indexes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
)


# TODO: there are many places that rely on these private methods existing in
# pandas.core.index
__all__ = [
"Index",
"MultiIndex",
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 @@ -5460,6 +5460,6 @@ def _validate_join_method(method):


def default_index(n):
from pandas.core.index import RangeIndex
from pandas.core.indexes.range import RangeIndex

return RangeIndex(0, n, name=None)
2 changes: 1 addition & 1 deletion pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
from pandas.core.dtypes.missing import _infer_fill_value, isna

import pandas.core.common as com
from pandas.core.index import Index, InvalidIndexError
from pandas.core.indexers import is_list_like_indexer, length_of_indexer
from pandas.core.indexes.api import Index, InvalidIndexError


# the supported indexers
Expand Down
8 changes: 6 additions & 2 deletions pandas/core/internals/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@
from pandas.core import algorithms, common as com
from pandas.core.arrays import Categorical
from pandas.core.construction import sanitize_array
from pandas.core.index import Index, ensure_index, get_objs_combined_axis
from pandas.core.indexes import base as ibase
from pandas.core.indexes.api import union_indexes
from pandas.core.indexes.api import (
Index,
ensure_index,
get_objs_combined_axis,
union_indexes,
)
from pandas.core.internals import (
create_block_manager_from_arrays,
create_block_manager_from_blocks,
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

import pandas.core.algorithms as algos
from pandas.core.base import PandasObject
from pandas.core.index import Index, MultiIndex, ensure_index
from pandas.core.indexers import maybe_convert_indices
from pandas.core.indexes.api import Index, MultiIndex, ensure_index

from pandas.io.formats.printing import pprint_thing

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/reshape/pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pandas.core.common as com
from pandas.core.frame import _shared_docs
from pandas.core.groupby import Grouper
from pandas.core.index import Index, MultiIndex, get_objs_combined_axis
from pandas.core.indexes.api 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
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/reshape/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pandas.core.arrays.categorical import factorize_from_iterable
from pandas.core.construction import extract_array
from pandas.core.frame import DataFrame
from pandas.core.index import Index, MultiIndex
from pandas.core.indexes.api import Index, MultiIndex
from pandas.core.series import Series
from pandas.core.sorting import (
compress_group_index,
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@
is_empty_data,
sanitize_array,
)
from pandas.core.index import (
from pandas.core.indexers import maybe_convert_indices
from pandas.core.indexes.accessors import CombinedDatetimelikeProperties
from pandas.core.indexes.api import (
Float64Index,
Index,
InvalidIndexError,
MultiIndex,
ensure_index,
)
from pandas.core.indexers import maybe_convert_indices
from pandas.core.indexes.accessors import CombinedDatetimelikeProperties
import pandas.core.indexes.base as ibase
from pandas.core.indexes.datetimes import DatetimeIndex
from pandas.core.indexes.period import PeriodIndex
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/window/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pandas.core.common as com
from pandas.core.generic import _shared_docs
from pandas.core.groupby.base import GroupByMixin
from pandas.core.index import MultiIndex
from pandas.core.indexes.api import MultiIndex

_shared_docs = dict(**_shared_docs)
_doc_template = """
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from pandas._typing import Axis, FrameOrSeries, Scalar
from pandas.core.base import DataError, PandasObject, SelectionMixin, ShallowMixin
import pandas.core.common as com
from pandas.core.index import Index, ensure_index
from pandas.core.indexes.api import Index, ensure_index
from pandas.core.window.common import (
WindowGroupByMixin,
_doc_template,
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
from pandas.core.arrays.timedeltas import TimedeltaArray
from pandas.core.base import PandasObject
import pandas.core.common as com
from pandas.core.index import Index, ensure_index
from pandas.core.indexes.api import Index, ensure_index
from pandas.core.indexes.datetimes import DatetimeIndex
from pandas.core.indexes.timedeltas import TimedeltaIndex

Expand Down Expand Up @@ -984,7 +984,7 @@ def to_html(
)

def _get_formatted_column_labels(self, frame: "DataFrame") -> List[List[str]]:
from pandas.core.index import _sparsify
from pandas.core.indexes.multi import _sparsify

columns = frame.columns

Expand Down
7 changes: 6 additions & 1 deletion pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@
from pandas.core import algorithms
from pandas.core.arrays import Categorical
from pandas.core.frame import DataFrame
from pandas.core.index import Index, MultiIndex, RangeIndex, ensure_index_from_sequences
from pandas.core.indexes.api import (
Index,
MultiIndex,
RangeIndex,
ensure_index_from_sequences,
)
from pandas.core.series import Series
from pandas.core.tools import datetimes as tools

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
from pandas.core.arrays.categorical import Categorical
import pandas.core.common as com
from pandas.core.computation.pytables import PyTablesExpr, maybe_expression
from pandas.core.index import ensure_index
from pandas.core.indexes.api import ensure_index

from pandas.io.common import _stringify_path
from pandas.io.formats.printing import adjoin, pprint_thing
Expand Down
3 changes: 1 addition & 2 deletions pandas/plotting/_matplotlib/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
)
from pandas.core.dtypes.generic import ABCSeries

from pandas import get_option
from pandas import Index, get_option
import pandas.core.common as com
from pandas.core.index import Index
from pandas.core.indexes.datetimes import date_range
from pandas.core.indexes.period import Period, PeriodIndex, period_range
import pandas.core.tools.datetimes as tools
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/arrays/categorical/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Index,
Interval,
IntervalIndex,
MultiIndex,
NaT,
Series,
Timestamp,
Expand Down Expand Up @@ -285,8 +286,6 @@ def test_constructor_with_generator(self):
tm.assert_categorical_equal(cat, exp)

# This uses xrange internally
from pandas.core.index import MultiIndex

MultiIndex.from_product([range(5), ["a", "b", "c"]])

# check that categories accept generators and sequences
Expand Down
9 changes: 7 additions & 2 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@
period_range,
)
from pandas.core.algorithms import safe_sort
from pandas.core.index import ensure_index, ensure_index_from_sequences
from pandas.core.indexes.api import Index, MultiIndex, _get_combined_index
from pandas.core.indexes.api import (
Index,
MultiIndex,
_get_combined_index,
ensure_index,
ensure_index_from_sequences,
)
from pandas.tests.indexes.common import Base
from pandas.tests.indexes.conftest import indices_dict
import pandas.util.testing as tm
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/multiindex/test_multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_multiindex_perf_warn(self):
}
).set_index(["jim", "joe"])

with tm.assert_produces_warning(PerformanceWarning, clear=[pd.core.index]):
with tm.assert_produces_warning(PerformanceWarning):
df.loc[(1, "z")]

df = df.iloc[[2, 1, 3, 0]]
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
Categorical,
CategoricalIndex,
DataFrame,
MultiIndex,
Series,
date_range,
isna,
notna,
)
from pandas.api.types import is_scalar
from pandas.core.index import MultiIndex
from pandas.core.indexes.datetimes import Timestamp
from pandas.core.indexes.timedeltas import TimedeltaIndex
import pandas.util.testing as tm
Expand Down
Loading