Skip to content

Commit 4b06ae4

Browse files
committed
REF: Created pandas.core.arrays
Moved pandas.core.categorical to arrays.
1 parent 4ebdc50 commit 4b06ae4

20 files changed

+27
-25
lines changed

pandas/_libs/parsers.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ from pandas.core.dtypes.common import (
5555
is_bool_dtype, is_object_dtype,
5656
is_datetime64_dtype,
5757
pandas_dtype)
58-
from pandas.core.categorical import Categorical
58+
from pandas.core.arrays import Categorical
5959
from pandas.core.dtypes.concat import union_categoricals
6060
import pandas.io.common as com
6161

pandas/core/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from pandas.core.algorithms import factorize, unique, value_counts
88
from pandas.core.dtypes.missing import isna, isnull, notna, notnull
9-
from pandas.core.categorical import Categorical
9+
from pandas.core.arrays import Categorical
1010
from pandas.core.groupby import Grouper
1111
from pandas.io.formats.format import set_eng_float_format
1212
from pandas.core.index import (Index, CategoricalIndex, Int64Index,

pandas/core/arrays/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .categorical import Categorical
File renamed without changes.

pandas/core/dtypes/concat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def union_categoricals(to_union, sort_categories=False, ignore_order=False):
314314
Categories (3, object): [b, c, a]
315315
"""
316316
from pandas import Index, Categorical, CategoricalIndex, Series
317-
from pandas.core.categorical import _recode_for_categories
317+
from pandas.core.arrays.categorical import _recode_for_categories
318318

319319
if len(to_union) == 0:
320320
raise ValueError('No Categoricals to union')

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
create_block_manager_from_arrays,
7878
create_block_manager_from_blocks)
7979
from pandas.core.series import Series
80-
from pandas.core.categorical import Categorical
80+
from pandas.core.arrays import Categorical
8181
import pandas.core.algorithms as algorithms
8282
from pandas.compat import (range, map, zip, lrange, lmap, lzip, StringIO, u,
8383
OrderedDict, raise_with_traceback)

pandas/core/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
DataError, SpecificationError)
4848
from pandas.core.index import (Index, MultiIndex,
4949
CategoricalIndex, _ensure_index)
50-
from pandas.core.categorical import Categorical
50+
from pandas.core.arrays import Categorical
5151
from pandas.core.frame import DataFrame
5252
from pandas.core.generic import NDFrame, _shared_docs
5353
from pandas.core.internals import BlockManager, make_block

pandas/core/indexes/category.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def _create_from_codes(self, codes, categories=None, ordered=None,
125125
CategoricalIndex
126126
"""
127127

128-
from pandas.core.categorical import Categorical
128+
from pandas.core.arrays import Categorical
129129
if categories is None:
130130
categories = self.categories
131131
if ordered is None:
@@ -162,7 +162,7 @@ def _create_categorical(self, data, categories=None, ordered=None,
162162
if not isinstance(data, ABCCategorical):
163163
if ordered is None and dtype is None:
164164
ordered = False
165-
from pandas.core.categorical import Categorical
165+
from pandas.core.arrays import Categorical
166166
data = Categorical(data, categories=categories, ordered=ordered,
167167
dtype=dtype)
168168
else:
@@ -462,7 +462,7 @@ def where(self, cond, other=None):
462462
other = self._na_value
463463
values = np.where(cond, self.values, other)
464464

465-
from pandas.core.categorical import Categorical
465+
from pandas.core.arrays import Categorical
466466
cat = Categorical(values,
467467
categories=self.categories,
468468
ordered=self.ordered)
@@ -775,7 +775,7 @@ def _delegate_method(self, name, *args, **kwargs):
775775
def _add_accessors(cls):
776776
""" add in Categorical accessor methods """
777777

778-
from pandas.core.categorical import Categorical
778+
from pandas.core.arrays import Categorical
779779
CategoricalIndex._add_delegate_accessors(
780780
delegate=Categorical, accessors=["rename_categories",
781781
"reorder_categories",

pandas/core/indexes/multi.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ def from_arrays(cls, arrays, sortorder=None, names=None):
11821182
if len(arrays[i]) != len(arrays[i - 1]):
11831183
raise ValueError('all arrays must be same length')
11841184

1185-
from pandas.core.categorical import _factorize_from_iterables
1185+
from pandas.core.arrays.categorical import _factorize_from_iterables
11861186

11871187
labels, levels = _factorize_from_iterables(arrays)
11881188
if names is None:
@@ -1276,7 +1276,7 @@ def from_product(cls, iterables, sortorder=None, names=None):
12761276
MultiIndex.from_arrays : Convert list of arrays to MultiIndex
12771277
MultiIndex.from_tuples : Convert list of tuples to MultiIndex
12781278
"""
1279-
from pandas.core.categorical import _factorize_from_iterables
1279+
from pandas.core.arrays.categorical import _factorize_from_iterables
12801280
from pandas.core.reshape.util import cartesian_product
12811281

12821282
if not is_list_like(iterables):
@@ -1749,7 +1749,7 @@ def _get_labels_for_sorting(self):
17491749
for sorting, where we need to disambiguate that -1 is not
17501750
a valid valid
17511751
"""
1752-
from pandas.core.categorical import Categorical
1752+
from pandas.core.arrays import Categorical
17531753

17541754
def cats(label):
17551755
return np.arange(np.array(label).max() + 1 if len(label) else 0,

pandas/core/internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
from pandas.core.index import Index, MultiIndex, _ensure_index
6161
from pandas.core.indexing import maybe_convert_indices, length_of_indexer
62-
from pandas.core.categorical import Categorical, _maybe_to_categorical
62+
from pandas.core.arrays.categorical import Categorical, _maybe_to_categorical
6363
from pandas.core.indexes.datetimes import DatetimeIndex
6464
from pandas.io.formats.printing import pprint_thing
6565

pandas/core/reshape/concat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from pandas.core.index import (_get_objs_combined_axis,
88
_ensure_index, _get_consensus_names,
99
_all_indexes_same)
10-
from pandas.core.categorical import (_factorize_from_iterable,
11-
_factorize_from_iterables)
10+
from pandas.core.arrays.categorical import (_factorize_from_iterable,
11+
_factorize_from_iterables)
1212
from pandas.core.internals import concatenate_block_managers
1313
from pandas.core import common as com
1414
from pandas.core.generic import NDFrame

pandas/core/reshape/melt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from pandas.core.dtypes.common import is_list_like
66
from pandas import compat
7-
from pandas.core.categorical import Categorical
7+
from pandas.core.arrays import Categorical
88

99
from pandas.core.dtypes.generic import ABCMultiIndex
1010

pandas/core/reshape/reshape.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
from pandas.core.sparse.array import SparseArray
2222
from pandas._libs.sparse import IntIndex
2323

24-
from pandas.core.categorical import Categorical, _factorize_from_iterable
24+
from pandas.core.arrays import Categorical
25+
from pandas.core.arrays.categorical import _factorize_from_iterable
2526
from pandas.core.sorting import (get_group_index, get_compressed_ids,
2627
compress_group_index, decons_obs_group_ids)
2728

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
from pandas.core.indexing import check_bool_indexer, maybe_convert_indices
5454
from pandas.core import generic, base
5555
from pandas.core.internals import SingleBlockManager
56-
from pandas.core.categorical import Categorical, CategoricalAccessor
56+
from pandas.core.arrays.categorical import Categorical, CategoricalAccessor
5757
from pandas.core.indexes.accessors import CombinedDatetimelikeProperties
5858
from pandas.core.indexes.datetimes import DatetimeIndex
5959
from pandas.core.indexes.timedeltas import TimedeltaIndex

pandas/core/sorting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def indexer_from_factorized(labels, shape, compress=True):
182182

183183

184184
def lexsort_indexer(keys, orders=None, na_position='last'):
185-
from pandas.core.categorical import Categorical
185+
from pandas.core.arrays import Categorical
186186

187187
labels = []
188188
shape = []

pandas/io/parsers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
_ensure_index_from_sequences)
2929
from pandas.core.series import Series
3030
from pandas.core.frame import DataFrame
31-
from pandas.core.categorical import Categorical
31+
from pandas.core.arrays import Categorical
3232
from pandas.core import algorithms
3333
from pandas.core.common import AbstractMethodError
3434
from pandas.io.date_converters import generic_parser

pandas/io/pytables.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
from pandas.errors import PerformanceWarning
3737
from pandas.core.common import _asarray_tuplesafe, _all_none
3838
from pandas.core.algorithms import match, unique
39-
from pandas.core.categorical import Categorical, _factorize_from_iterables
39+
from pandas.core.arrays.categorical import (Categorical,
40+
_factorize_from_iterables)
4041
from pandas.core.internals import (BlockManager, make_block,
4142
_block2d_to_blocknd,
4243
_factor_indexer, _block_shape)

pandas/io/stata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from pandas.compat import (lrange, lmap, lzip, text_type, string_types, range,
2525
zip, BytesIO)
2626
from pandas.core.base import StringMixin
27-
from pandas.core.categorical import Categorical
27+
from pandas.core.arrays import Categorical
2828
from pandas.core.dtypes.common import (is_categorical_dtype, _ensure_object,
2929
is_datetime64_dtype)
3030
from pandas.core.frame import DataFrame

pandas/tests/categorical/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pandas.util.testing as tm
88
from pandas import Categorical, CategoricalIndex, Index, Series, DataFrame
99

10-
from pandas.core.categorical import _recode_for_categories
10+
from pandas.core.arrays.categorical import _recode_for_categories
1111
from pandas.tests.categorical.common import TestCategorical
1212

1313

pandas/tests/series/test_api.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,7 @@ def test_cat_accessor(self):
511511

512512
def test_cat_accessor_api(self):
513513
# GH 9322
514-
from pandas.core.categorical import CategoricalAccessor
515-
514+
from pandas.core.arrays.categorical import CategoricalAccessor
516515
assert Series.cat is CategoricalAccessor
517516
s = Series(list('aabbcde')).astype('category')
518517
assert isinstance(s.cat, CategoricalAccessor)

0 commit comments

Comments
 (0)