CLN: reorg type inference & introspection by jreback · Pull Request #13147 · pandas-dev/pandas (original) (raw)

So this is the big boy. destroyed core/common.py and split up. Now have no more import issues and a nice private API. Nothing is exported by default. You have to explicity import things.

In [1]: from pandas import api

In [2]: dir(api)
Out[2]: 
['__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 '__path__',
 'is_any_int_dtype',
 'is_bool',
 'is_bool_dtype',
 'is_categorical',
 'is_categorical_dtype',
 'is_complex',
 'is_complex_dtype',
 'is_datetime64_any_dtype',
 'is_datetime64_dtype',
 'is_datetime64_ns_dtype',
 'is_datetime64tz_dtype',
 'is_datetimetz',
 'is_dtype_equal',
 'is_extension_type',
 'is_float',
 'is_float_dtype',
 'is_floating_dtype',
 'is_int64_dtype',
 'is_integer',
 'is_integer_dtype',
 'is_number',
 'is_numeric_dtype',
 'is_object_dtype',
 'is_scalar',
 'is_sparse',
 'is_string_dtype',
 'is_timedelta64_dtype',
 'is_timedelta64_ns_dtype',
 'np',
 'pandas_dtype',
 'types']

Previously pandas.core.common was a huge namespace of everything under the sun. As a result, you often had to do com. imports to do stuff, and sometimes import inside a function.

These are essentially hierarchically arrange in order of deps.

pandas.core.common now doesn't depend on anything else.

from pandas.types.common import is_integer or whatever at the top of any file and it will just work. Further almost all references to com gone.

This only change was I added array_equivalent to the pd. namespace, as formerly it was accessible as by:

from pandas.core.common import array_equivalent

There should be NO user facing changes at all, but I will put a note that warns if people were using the 'private' API (IOW if they were directly importing stuff), then things have moved.