Skip to content

Commit 005a09e

Browse files
committed
CLN: move top-level dirs
xref #13634 pandas.types -> pandas.core.dtypes pandas.computation -> pandas.core.computation pandas.sparse -> pandas.core.sparse Author: Jeff Reback <jeff.reback@twosigma.com> Closes #15998 from jreback/move_types and squashes the following commits: 5fe80ae [Jeff Reback] move fixtures to top-level conftest 9d36104 [Jeff Reback] moar ci d165a3f [Jeff Reback] more verbose built test 3ca5ba3 [Jeff Reback] pep f1505d7 [Jeff Reback] try with pyargs f63b76c [Jeff Reback] CLN: pandas.sparse -> pandas.core.sparse 751fb33 [Jeff Reback] move privacy changes to development section 221a7b5 [Jeff Reback] rename .typed -> .dtypes 290315e [Jeff Reback] move pandas.api.lib.infer_dtype -> pandas.api.types ba32641 [Jeff Reback] CLN: move pandas.computation -> pandas.core.computation bbdb1ee [Jeff Reback] CLN: move pandas.types -> pandas.core.typed
1 parent 7993fc8 commit 005a09e

File tree

186 files changed

+1021
-891
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+1021
-891
lines changed

asv_bench/benchmarks/binary_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .pandas_vb_common import *
2-
import pandas.computation.expressions as expr
2+
import pandas.core.computation.expressions as expr
33

44

55
class Ops(object):

asv_bench/benchmarks/categoricals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .pandas_vb_common import *
22
try:
3-
from pandas.types.concat import union_categoricals
3+
from pandas.core.dtypes.concat import union_categoricals
44
except ImportError:
55
pass
66

asv_bench/benchmarks/eval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .pandas_vb_common import *
22
import pandas as pd
3-
import pandas.computation.expressions as expr
3+
import pandas.core.computation.expressions as expr
44

55

66
class Eval(object):

asv_bench/benchmarks/indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .pandas_vb_common import *
22
try:
3-
import pandas.computation.expressions as expr
3+
import pandas.core.computation.expressions as expr
44
except:
55
expr = None
66

asv_bench/benchmarks/sparse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .pandas_vb_common import *
2-
import pandas.sparse.series
2+
import pandas.core.sparse.series
33
import scipy.sparse
44
from pandas.core.sparse import SparseSeries, SparseDataFrame
55
from pandas.core.sparse import SparseDataFrame
@@ -37,7 +37,7 @@ def setup(self):
3737
self.A = scipy.sparse.coo_matrix(([3.0, 1.0, 2.0], ([1, 0, 0], [0, 2, 3])), shape=(100, 100))
3838

3939
def time_sparse_series_from_coo(self):
40-
self.ss = pandas.sparse.series.SparseSeries.from_coo(self.A)
40+
self.ss = pandas.core.sparse.series.SparseSeries.from_coo(self.A)
4141

4242

4343
class sparse_series_to_coo(object):

ci/install_travis.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ if [ "$BUILD_TEST" ]; then
123123

124124
# build & install testing
125125
echo ["Starting installation test."]
126+
rm -rf dist
126127
python setup.py clean
127128
python setup.py build_ext --inplace
128129
python setup.py sdist --formats=gztar

ci/script_multi.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 429496
1919
echo PYTHONHASHSEED=$PYTHONHASHSEED
2020

2121
if [ "$BUILD_TEST" ]; then
22+
echo "build-test"
2223
cd /tmp
24+
pwd
25+
conda list pandas
26+
echo "running"
2327
python -c "import pandas; pandas.test(['-n 2'])"
2428
elif [ "$DOC" ]; then
2529
echo "We are not running pytest as this is a doc-build"

doc/source/categorical.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ will be the union of the categories being combined.
673673

674674
.. ipython:: python
675675
676-
from pandas.types.concat import union_categoricals
676+
from pandas.api.types import union_categoricals
677677
a = pd.Categorical(["b", "c"])
678678
b = pd.Categorical(["a", "b"])
679679
union_categoricals([a, b])

doc/source/whatsnew/v0.20.0.txt

Lines changed: 72 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ Highlights include:
2121
- Support for S3 handling now uses ``s3fs``, see :ref:`here <whatsnew_0200.api_breaking.s3>`
2222
- Google BigQuery support now uses the ``pandas-gbq`` library, see :ref:`here <whatsnew_0200.api_breaking.gbq>`
2323
- Switched the test framework to use `pytest <http://doc.pytest.org/en/latest>`__ (:issue:`13097`)
24-
- The ``pandas.tools.plotting`` module has been deprecated, moved to ``pandas.plotting``. See :ref:`here <whatsnew_0200.api_breaking.plotting>`
2524

25+
.. warning::
26+
27+
Pandas has changed the internal structure and layout of the codebase.
28+
This can affect imports that are not from the top-level ``pandas.*`` namespace, please see the changes :ref:`here <whatsnew_0200.privacy>`.
2629

2730
Check the :ref:`API Changes <whatsnew_0200.api_breaking>` and :ref:`deprecations <whatsnew_0200.deprecations>` before updating.
2831

@@ -489,7 +492,7 @@ Other Enhancements
489492

490493

491494
- ``TimedeltaIndex`` now has a custom datetick formatter specifically designed for nanosecond level precision (:issue:`8711`)
492-
- ``pd.types.concat.union_categoricals`` gained the ``ignore_ordered`` argument to allow ignoring the ordered attribute of unioned categoricals (:issue:`13410`). See the :ref:`categorical union docs <categorical.union>` for more information.
495+
- ``pd.api.types.union_categoricals`` gained the ``ignore_ordered`` argument to allow ignoring the ordered attribute of unioned categoricals (:issue:`13410`). See the :ref:`categorical union docs <categorical.union>` for more information.
493496
- ``DataFrame.to_latex()`` and ``DataFrame.to_string()`` now allow optional header aliases. (:issue:`15536`)
494497
- Re-enable the ``parse_dates`` keyword of ``pd.read_excel()`` to parse string columns as dates (:issue:`14326`)
495498
- Added ``.empty`` property to subclasses of ``Index``. (:issue:`15270`)
@@ -558,31 +561,6 @@ Using ``.iloc``. Here we will get the location of the 'A' column, then use *posi
558561
df.iloc[[0, 2], df.columns.get_loc('A')]
559562

560563

561-
.. _whatsnew_0200.api_breaking.deprecate_plotting
562-
563-
Deprecate .plotting
564-
^^^^^^^^^^^^^^^^^^^
565-
566-
The ``pandas.tools.plotting`` module has been deprecated, in favor of the top level ``pandas.plotting`` module. All the public plotting functions are now available
567-
from ``pandas.plotting`` (:issue:`12548`).
568-
569-
Furthermore, the top-level ``pandas.scatter_matrix`` and ``pandas.plot_params`` are deprecated.
570-
Users can import these from ``pandas.plotting`` as well.
571-
572-
Previous script:
573-
574-
.. code-block:: python
575-
576-
pd.tools.plotting.scatter_matrix(df)
577-
pd.scatter_matrix(df)
578-
579-
Should be changed to:
580-
581-
.. code-block:: python
582-
583-
pd.plotting.scatter_matrix(df)
584-
585-
586564
.. _whatsnew_0200.api_breaking.deprecate_panel:
587565

588566
Deprecate Panel
@@ -1026,34 +1004,6 @@ New Behavior:
10261004
In [11]: index.memory_usage(deep=True)
10271005
Out[11]: 260
10281006

1029-
.. _whatsnew_0200.api_breaking.extensions:
1030-
1031-
Extension Modules Moved
1032-
^^^^^^^^^^^^^^^^^^^^^^^
1033-
1034-
Some formerly public c/c++/cython extension modules have been moved and/or renamed. These are all removed from the public API.
1035-
If indicated, a deprecation warning will be issued if you reference that module. (:issue:`12588`)
1036-
1037-
.. csv-table::
1038-
:header: "Previous Location", "New Location", "Deprecated"
1039-
:widths: 30, 30, 4
1040-
1041-
"pandas.lib", "pandas._libs.lib", "X"
1042-
"pandas.tslib", "pandas._libs.tslib", "X"
1043-
"pandas._join", "pandas._libs.join", ""
1044-
"pandas._period", "pandas._libs.period", ""
1045-
"pandas.msgpack", "pandas.io.msgpack", ""
1046-
"pandas.index", "pandas._libs.index", ""
1047-
"pandas.algos", "pandas._libs.algos", ""
1048-
"pandas.hashtable", "pandas._libs.hashtable", ""
1049-
"pandas.json", "pandas.io.json.libjson", "X"
1050-
"pandas.parser", "pandas.io.libparsers", "X"
1051-
"pandas.io.sas.saslib", "pandas.io.sas.libsas", ""
1052-
"pandas._testing", "pandas.util.libtesting", ""
1053-
"pandas._sparse", "pandas.sparse.libsparse", ""
1054-
"pandas._hash", "pandas.tools.libhash", ""
1055-
"pandas._window", "pandas.core.libwindow", ""
1056-
10571007
.. _whatsnew_0200.api_breaking.sort_index:
10581008

10591009
DataFrame.sort_index changes
@@ -1354,10 +1304,74 @@ Other API Changes
13541304
- ``DataFrame`` and ``Panel`` constructors with invalid input will now raise ``ValueError`` rather than ``pandas.core.common.PandasError``, if called with scalar inputs and not axes; The exception ``PandasError`` is removed as well. (:issue:`15541`)
13551305
- The exception ``pandas.core.common.AmbiguousIndexError`` is removed as it is not referenced (:issue:`15541`)
13561306

1357-
.. _whatsnew_0200.develop:
1307+
.. _whatsnew_0200.privacy:
1308+
1309+
Privacy Changes
1310+
~~~~~~~~~~~~~~~
1311+
1312+
.. _whatsnew_0200.privacy.extensions:
1313+
1314+
Modules Privacy Has Changed
1315+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
1316+
1317+
Some formerly public python/c/c++/cython extension modules have been moved and/or renamed. These are all removed from the public API.
1318+
Furthermore, the ``pandas.core``, ``pandas.io``, and ``pandas.util`` top-level modules are now considered to be PRIVATE.
1319+
If indicated, a deprecation warning will be issued if you reference theses modules. (:issue:`12588`)
1320+
1321+
.. csv-table::
1322+
:header: "Previous Location", "New Location", "Deprecated"
1323+
:widths: 30, 30, 4
1324+
1325+
"pandas.lib", "pandas._libs.lib", "X"
1326+
"pandas.tslib", "pandas._libs.tslib", "X"
1327+
"pandas.computation", "pandas.core.computation", ""
1328+
"pandas.msgpack", "pandas.io.msgpack", ""
1329+
"pandas.index", "pandas._libs.index", ""
1330+
"pandas.algos", "pandas._libs.algos", ""
1331+
"pandas.hashtable", "pandas._libs.hashtable", ""
1332+
"pandas.json", "pandas.io.json.libjson", "X"
1333+
"pandas.parser", "pandas.io.libparsers", "X"
1334+
"pandas.sparse", "pandas.core.sparse", ""
1335+
"pandas.types", "pandas.core.dtypes", ""
1336+
"pandas.io.sas.saslib", "pandas.io.sas.libsas", ""
1337+
"pandas._join", "pandas._libs.join", ""
1338+
"pandas._hash", "pandas.tools.libhash", ""
1339+
"pandas._period", "pandas._libs.period", ""
1340+
"pandas._sparse", "pandas.core.sparse.libsparse", ""
1341+
"pandas._testing", "pandas.util.libtesting", ""
1342+
"pandas._window", "pandas.core.libwindow", ""
1343+
1344+
- The function :func:`~pandas.api.type.union_categoricals` is now importable from ``pandas.api.types``, formerly from ``pandas.types.concat`` (:issue:`15998`)
1345+
1346+
.. _whatsnew_0200.privacy.deprecate_plotting
1347+
1348+
Deprecate .plotting
1349+
^^^^^^^^^^^^^^^^^^^
1350+
1351+
The ``pandas.tools.plotting`` module has been deprecated, in favor of the top level ``pandas.plotting`` module. All the public plotting functions are now available
1352+
from ``pandas.plotting`` (:issue:`12548`).
1353+
1354+
Furthermore, the top-level ``pandas.scatter_matrix`` and ``pandas.plot_params`` are deprecated.
1355+
Users can import these from ``pandas.plotting`` as well.
1356+
1357+
Previous script:
1358+
1359+
.. code-block:: python
1360+
1361+
pd.tools.plotting.scatter_matrix(df)
1362+
pd.scatter_matrix(df)
1363+
1364+
Should be changed to:
1365+
1366+
.. code-block:: python
1367+
1368+
pd.plotting.scatter_matrix(df)
1369+
1370+
1371+
.. _whatsnew_0200.privacy.development:
13581372

1359-
Development Changes
1360-
~~~~~~~~~~~~~~~~~~~
1373+
Other Developement Changes
1374+
^^^^^^^^^^^^^^^^^^^^^^^^^^
13611375

13621376
- Building pandas for development now requires ``cython >= 0.23`` (:issue:`14831`)
13631377
- Require at least 0.23 version of cython to avoid problems with character encodings (:issue:`14699`)

pandas/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
import pandas.core.config_init
4141

4242
from pandas.core.api import *
43-
from pandas.sparse.api import *
43+
from pandas.core.sparse.api import *
4444
from pandas.stats.api import *
4545
from pandas.tseries.api import *
46-
from pandas.computation.api import *
46+
from pandas.core.computation.api import *
4747

4848
from pandas.tools.concat import concat
4949
from pandas.tools.merge import (merge, ordered_merge,

pandas/api/types/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" public toolkit API """
22

3-
from pandas.types.api import * # noqa
3+
from pandas.core.dtypes.api import * # noqa
4+
from pandas.core.dtypes.concat import union_categoricals # noqa
45
del np # noqa

pandas/compat/numpy/function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from pandas.util.validators import (validate_args, validate_kwargs,
2323
validate_args_and_kwargs)
2424
from pandas.errors import UnsupportedFunctionCall
25-
from pandas.types.common import is_integer, is_bool
25+
from pandas.core.dtypes.common import is_integer, is_bool
2626
from pandas.compat import OrderedDict
2727

2828

pandas/compat/pickle_compat.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,24 @@ def load_reduce(self):
6767
('pandas.core.series', 'TimeSeries'):
6868
('pandas.core.series', 'Series'),
6969
('pandas.sparse.series', 'SparseTimeSeries'):
70-
('pandas.sparse.series', 'SparseSeries'),
70+
('pandas.core.sparse.series', 'SparseSeries'),
7171

7272
# 12588, extensions moving
7373
('pandas._sparse', 'BlockIndex'):
74-
('pandas.sparse.libsparse', 'BlockIndex'),
74+
('pandas.core.sparse.libsparse', 'BlockIndex'),
7575
('pandas.tslib', 'Timestamp'):
7676
('pandas._libs.tslib', 'Timestamp'),
7777
('pandas.tslib', '__nat_unpickle'):
7878
('pandas._libs.tslib', '__nat_unpickle'),
79-
('pandas._period', 'Period'): ('pandas._libs.period', 'Period')
79+
('pandas._period', 'Period'): ('pandas._libs.period', 'Period'),
80+
81+
# 15998 top-level dirs moving
82+
('pandas.sparse.array', 'SparseArray'):
83+
('pandas.core.sparse.array', 'SparseArray'),
84+
('pandas.sparse.series', 'SparseSeries'):
85+
('pandas.core.sparse.series', 'SparseSeries'),
86+
('pandas.sparse.frame', 'SparseDataFrame'):
87+
('pandas.core.sparse.frame', 'SparseDataFrame')
8088
}
8189

8290

pandas/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import numpy
44
import pandas
5+
import pandas.util.testing as tm
56

67

78
def pytest_addoption(parser):
@@ -30,3 +31,10 @@ def pytest_runtest_setup(item):
3031
def add_imports(doctest_namespace):
3132
doctest_namespace['np'] = numpy
3233
doctest_namespace['pd'] = pandas
34+
35+
36+
@pytest.fixture(params=['bsr', 'coo', 'csc', 'csr', 'dia', 'dok', 'lil'])
37+
def spmatrix(request):
38+
tm._skip_if_no_scipy()
39+
from scipy import sparse
40+
return getattr(sparse, request.param + '_matrix')

pandas/core/algorithms.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
import numpy as np
88

99
from pandas import compat, _np_version_under1p8
10-
from pandas.types.cast import maybe_promote
11-
from pandas.types.generic import (ABCSeries, ABCIndex,
12-
ABCIndexClass, ABCCategorical)
13-
from pandas.types.common import (
10+
from pandas.core.dtypes.cast import maybe_promote
11+
from pandas.core.dtypes.generic import (
12+
ABCSeries, ABCIndex,
13+
ABCIndexClass, ABCCategorical)
14+
from pandas.core.dtypes.common import (
1415
is_unsigned_integer_dtype, is_signed_integer_dtype,
1516
is_integer_dtype, is_complex_dtype,
1617
is_categorical_dtype, is_sparse,
@@ -25,9 +26,9 @@
2526
_ensure_float64, _ensure_uint64,
2627
_ensure_int64)
2728
from pandas.compat.numpy import _np_version_under1p10
28-
from pandas.types.missing import isnull
29+
from pandas.core.dtypes.missing import isnull
2930

30-
import pandas.core.common as com
31+
from pandas.core import common as com
3132
from pandas.compat import string_types
3233
from pandas._libs import algos, lib, hashtable as htable
3334
from pandas._libs.tslib import iNaT

pandas/core/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66

77
from pandas.core.algorithms import factorize, unique, value_counts
8-
from pandas.types.missing import isnull, notnull
8+
from pandas.core.dtypes.missing import isnull, notnull
99
from pandas.core.categorical import Categorical
1010
from pandas.core.groupby import Grouper
1111
from pandas.formats.format import set_eng_float_format

pandas/core/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from pandas.compat import builtins
77
import numpy as np
88

9-
from pandas.types.missing import isnull
10-
from pandas.types.generic import ABCDataFrame, ABCSeries, ABCIndexClass
11-
from pandas.types.common import is_object_dtype, is_list_like, is_scalar
9+
from pandas.core.dtypes.missing import isnull
10+
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries, ABCIndexClass
11+
from pandas.core.dtypes.common import is_object_dtype, is_list_like, is_scalar
1212
from pandas.util.validators import validate_bool_kwarg
1313

1414
from pandas.core import common as com
@@ -725,7 +725,7 @@ def _aggregate_multiple_funcs(self, arg, _level, _axis):
725725
# we are concatting non-NDFrame objects,
726726
# e.g. a list of scalars
727727

728-
from pandas.types.cast import is_nested_object
728+
from pandas.core.dtypes.cast import is_nested_object
729729
from pandas import Series
730730
result = Series(results, index=keys, name=self.name)
731731
if is_nested_object(result):

0 commit comments

Comments
 (0)