From e0133b7fc3d13cd2a69b3cf0d26adbe0e6ae5e5c Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Fri, 6 Mar 2020 11:51:29 +0200 Subject: [PATCH 1/3] CLN: Using ABCClass instead of Class in "isinstance()" --- pandas/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/__init__.py b/pandas/__init__.py index 2b9a461e0e95d..da016e4d966bf 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -116,6 +116,7 @@ ) from pandas.core.arrays.sparse import SparseDtype +from pandas.core.dtypes.generic import ABCSparseArray from pandas.tseries.api import infer_freq from pandas.tseries import offsets @@ -341,7 +342,7 @@ class __SparseArray(type): SparseArray = sa def __instancecheck__(cls, other): - return isinstance(other, cls.SparseArray) + return isinstance(other, ABCSparseArray) class __SparseArraySub(metaclass=__SparseArray): def emit_warning(dummy=0): From 26b8ad9d907f8f24b5838eb43ae30000af0d0a93 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Fri, 6 Mar 2020 11:55:38 +0200 Subject: [PATCH 2/3] isort formatting --- pandas/__init__.py | 219 +++++++++++++++++++++------------------------ 1 file changed, 102 insertions(+), 117 deletions(-) diff --git a/pandas/__init__.py b/pandas/__init__.py index da016e4d966bf..82d7740a862a1 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -18,170 +18,155 @@ ) del hard_dependencies, dependency, missing_dependencies +from pandas._config import ( + describe_option, + get_option, + option_context, + options, + reset_option, + set_option, +) + # numpy compat from pandas.compat.numpy import ( + _is_numpy_dev, _np_version_under1p14, _np_version_under1p15, _np_version_under1p16, _np_version_under1p17, _np_version_under1p18, - _is_numpy_dev, ) +from pandas.util._print_versions import show_versions +from pandas.util._tester import test -try: - from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib -except ImportError as e: # pragma: no cover - # hack but overkill to use re - module = str(e).replace("cannot import name ", "") - raise ImportError( - f"C extension: {module} not built. If you want to import " - "pandas from the source directory, you may need to run " - "'python setup.py build_ext --inplace --force' to build the C extensions first." - ) from e - -from pandas._config import ( - get_option, - set_option, - reset_option, - describe_option, - option_context, - options, -) +from pandas.core.dtypes.generic import ABCSparseArray # let init-time option registration happen +import pandas.api +import pandas.arrays +from pandas.core.arrays.sparse import SparseDtype +from pandas.core.computation.api import eval import pandas.core.config_init +from pandas.core.reshape.api import ( + concat, + crosstab, + cut, + get_dummies, + lreshape, + melt, + merge, + merge_asof, + merge_ordered, + pivot, + pivot_table, + qcut, + wide_to_long, +) +import pandas.testing -from pandas.core.api import ( - # dtype +from pandas.io.json import _json_normalize as json_normalize +from pandas.tseries import offsets +from pandas.tseries.api import infer_freq + +# use the closest tagged version if possible +from ._version import get_versions + +from pandas.core.api import ( # dtype; missing; indexes; tseries; conversion; misc + NA, + BooleanDtype, + Categorical, + CategoricalDtype, + CategoricalIndex, + DataFrame, + DateOffset, + DatetimeIndex, + DatetimeTZDtype, + Float64Index, + Grouper, + Index, + IndexSlice, Int8Dtype, Int16Dtype, Int32Dtype, Int64Dtype, + Int64Index, + Interval, + IntervalDtype, + IntervalIndex, + MultiIndex, + NamedAgg, + NaT, + Period, + PeriodDtype, + PeriodIndex, + RangeIndex, + Series, + StringDtype, + Timedelta, + TimedeltaIndex, + Timestamp, UInt8Dtype, UInt16Dtype, UInt32Dtype, UInt64Dtype, - CategoricalDtype, - PeriodDtype, - IntervalDtype, - DatetimeTZDtype, - StringDtype, - BooleanDtype, - # missing - NA, + UInt64Index, + array, + bdate_range, + date_range, + factorize, + interval_range, isna, isnull, notna, notnull, - # indexes - Index, - CategoricalIndex, - Int64Index, - UInt64Index, - RangeIndex, - Float64Index, - MultiIndex, - IntervalIndex, - TimedeltaIndex, - DatetimeIndex, - PeriodIndex, - IndexSlice, - # tseries - NaT, - Period, period_range, - Timedelta, + set_eng_float_format, timedelta_range, - Timestamp, - date_range, - bdate_range, - Interval, - interval_range, - DateOffset, - # conversion - to_numeric, to_datetime, + to_numeric, to_timedelta, - # misc - Grouper, - factorize, unique, value_counts, - NamedAgg, - array, - Categorical, - set_eng_float_format, - Series, - DataFrame, ) -from pandas.core.arrays.sparse import SparseDtype -from pandas.core.dtypes.generic import ABCSparseArray - -from pandas.tseries.api import infer_freq -from pandas.tseries import offsets - -from pandas.core.computation.api import eval - -from pandas.core.reshape.api import ( - concat, - lreshape, - melt, - wide_to_long, - merge, - merge_asof, - merge_ordered, - crosstab, - pivot, - pivot_table, - get_dummies, - cut, - qcut, -) - -import pandas.api -from pandas.util._print_versions import show_versions - -from pandas.io.api import ( - # excel +from pandas.io.api import ( # excel; parsers; pickle; pytables; sql; misc ExcelFile, ExcelWriter, - read_excel, - # parsers - read_csv, - read_fwf, - read_table, - # pickle - read_pickle, - to_pickle, - # pytables HDFStore, - read_hdf, - # sql - read_sql, - read_sql_query, - read_sql_table, - # misc read_clipboard, - read_parquet, - read_orc, + read_csv, + read_excel, read_feather, + read_fwf, read_gbq, + read_hdf, read_html, read_json, - read_stata, + read_orc, + read_parquet, + read_pickle, read_sas, read_spss, + read_sql, + read_sql_query, + read_sql_table, + read_stata, + read_table, + to_pickle, ) -from pandas.io.json import _json_normalize as json_normalize -from pandas.util._tester import test -import pandas.testing -import pandas.arrays +try: + from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib +except ImportError as e: # pragma: no cover + # hack but overkill to use re + module = str(e).replace("cannot import name ", "") + raise ImportError( + f"C extension: {module} not built. If you want to import " + "pandas from the source directory, you may need to run " + "'python setup.py build_ext --inplace --force' to build the C extensions first." + ) from e -# use the closest tagged version if possible -from ._version import get_versions v = get_versions() __version__ = v.get("closest-tag", v["version"]) From aad4788948e988056b1a8a1d31f96a3eb81513cd Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Fri, 6 Mar 2020 12:06:27 +0200 Subject: [PATCH 3/3] Revert "isort formatting" This reverts commit 26b8ad9d907f8f24b5838eb43ae30000af0d0a93. --- pandas/__init__.py | 219 ++++++++++++++++++++++++--------------------- 1 file changed, 117 insertions(+), 102 deletions(-) diff --git a/pandas/__init__.py b/pandas/__init__.py index 82d7740a862a1..da016e4d966bf 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -18,155 +18,170 @@ ) del hard_dependencies, dependency, missing_dependencies -from pandas._config import ( - describe_option, - get_option, - option_context, - options, - reset_option, - set_option, -) - # numpy compat from pandas.compat.numpy import ( - _is_numpy_dev, _np_version_under1p14, _np_version_under1p15, _np_version_under1p16, _np_version_under1p17, _np_version_under1p18, + _is_numpy_dev, ) -from pandas.util._print_versions import show_versions -from pandas.util._tester import test -from pandas.core.dtypes.generic import ABCSparseArray +try: + from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib +except ImportError as e: # pragma: no cover + # hack but overkill to use re + module = str(e).replace("cannot import name ", "") + raise ImportError( + f"C extension: {module} not built. If you want to import " + "pandas from the source directory, you may need to run " + "'python setup.py build_ext --inplace --force' to build the C extensions first." + ) from e -# let init-time option registration happen -import pandas.api -import pandas.arrays -from pandas.core.arrays.sparse import SparseDtype -from pandas.core.computation.api import eval -import pandas.core.config_init -from pandas.core.reshape.api import ( - concat, - crosstab, - cut, - get_dummies, - lreshape, - melt, - merge, - merge_asof, - merge_ordered, - pivot, - pivot_table, - qcut, - wide_to_long, +from pandas._config import ( + get_option, + set_option, + reset_option, + describe_option, + option_context, + options, ) -import pandas.testing -from pandas.io.json import _json_normalize as json_normalize -from pandas.tseries import offsets -from pandas.tseries.api import infer_freq - -# use the closest tagged version if possible -from ._version import get_versions +# let init-time option registration happen +import pandas.core.config_init -from pandas.core.api import ( # dtype; missing; indexes; tseries; conversion; misc - NA, - BooleanDtype, - Categorical, - CategoricalDtype, - CategoricalIndex, - DataFrame, - DateOffset, - DatetimeIndex, - DatetimeTZDtype, - Float64Index, - Grouper, - Index, - IndexSlice, +from pandas.core.api import ( + # dtype Int8Dtype, Int16Dtype, Int32Dtype, Int64Dtype, - Int64Index, - Interval, - IntervalDtype, - IntervalIndex, - MultiIndex, - NamedAgg, - NaT, - Period, - PeriodDtype, - PeriodIndex, - RangeIndex, - Series, - StringDtype, - Timedelta, - TimedeltaIndex, - Timestamp, UInt8Dtype, UInt16Dtype, UInt32Dtype, UInt64Dtype, - UInt64Index, - array, - bdate_range, - date_range, - factorize, - interval_range, + CategoricalDtype, + PeriodDtype, + IntervalDtype, + DatetimeTZDtype, + StringDtype, + BooleanDtype, + # missing + NA, isna, isnull, notna, notnull, + # indexes + Index, + CategoricalIndex, + Int64Index, + UInt64Index, + RangeIndex, + Float64Index, + MultiIndex, + IntervalIndex, + TimedeltaIndex, + DatetimeIndex, + PeriodIndex, + IndexSlice, + # tseries + NaT, + Period, period_range, - set_eng_float_format, + Timedelta, timedelta_range, - to_datetime, + Timestamp, + date_range, + bdate_range, + Interval, + interval_range, + DateOffset, + # conversion to_numeric, + to_datetime, to_timedelta, + # misc + Grouper, + factorize, unique, value_counts, + NamedAgg, + array, + Categorical, + set_eng_float_format, + Series, + DataFrame, ) -from pandas.io.api import ( # excel; parsers; pickle; pytables; sql; misc +from pandas.core.arrays.sparse import SparseDtype +from pandas.core.dtypes.generic import ABCSparseArray + +from pandas.tseries.api import infer_freq +from pandas.tseries import offsets + +from pandas.core.computation.api import eval + +from pandas.core.reshape.api import ( + concat, + lreshape, + melt, + wide_to_long, + merge, + merge_asof, + merge_ordered, + crosstab, + pivot, + pivot_table, + get_dummies, + cut, + qcut, +) + +import pandas.api +from pandas.util._print_versions import show_versions + +from pandas.io.api import ( + # excel ExcelFile, ExcelWriter, + read_excel, + # parsers + read_csv, + read_fwf, + read_table, + # pickle + read_pickle, + to_pickle, + # pytables HDFStore, + read_hdf, + # sql + read_sql, + read_sql_query, + read_sql_table, + # misc read_clipboard, - read_csv, - read_excel, + read_parquet, + read_orc, read_feather, - read_fwf, read_gbq, - read_hdf, read_html, read_json, - read_orc, - read_parquet, - read_pickle, + read_stata, read_sas, read_spss, - read_sql, - read_sql_query, - read_sql_table, - read_stata, - read_table, - to_pickle, ) +from pandas.io.json import _json_normalize as json_normalize -try: - from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib -except ImportError as e: # pragma: no cover - # hack but overkill to use re - module = str(e).replace("cannot import name ", "") - raise ImportError( - f"C extension: {module} not built. If you want to import " - "pandas from the source directory, you may need to run " - "'python setup.py build_ext --inplace --force' to build the C extensions first." - ) from e +from pandas.util._tester import test +import pandas.testing +import pandas.arrays +# use the closest tagged version if possible +from ._version import get_versions v = get_versions() __version__ = v.get("closest-tag", v["version"])