ARROW-1066: [Python] pandas 0.20.1 deprecation of pd.lib causes a warning on import
Author: Jeff Reback <jeff.reb...@twosigma.com> Closes #715 from jreback/pandas_compat and squashes the following commits: 842b19f [Jeff Reback] COMPAT: pandas 0.20.1 deprecation of pd.lib causes a warning on import Project: http://git-wip-us.apache.org/repos/asf/arrow/repo Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/078357af Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/078357af Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/078357af Branch: refs/heads/master Commit: 078357af32514502200a2fb83b0376c6c36f623c Parents: 1cb18d5 Author: Jeff Reback <jeff.reb...@twosigma.com> Authored: Wed May 24 17:18:45 2017 -0400 Committer: Wes McKinney <wes.mckin...@twosigma.com> Committed: Wed May 31 13:45:48 2017 -0400 ---------------------------------------------------------------------- python/pyarrow/feather.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/arrow/blob/078357af/python/pyarrow/feather.py ---------------------------------------------------------------------- diff --git a/python/pyarrow/feather.py b/python/pyarrow/feather.py index 34783a7..9f40ab4 100644 --- a/python/pyarrow/feather.py +++ b/python/pyarrow/feather.py @@ -26,6 +26,11 @@ from pyarrow.lib import FeatherError # noqa from pyarrow.lib import Table import pyarrow.lib as ext +try: + infer_dtype = pdapi.infer_dtype +except AttributeError: + infer_dtype = pd.lib.infer_dtype + if LooseVersion(pd.__version__) < '0.17.0': raise ImportError("feather requires pandas >= 0.17.0") @@ -75,7 +80,7 @@ class FeatherWriter(object): col = df.iloc[:, i] if pdapi.is_object_dtype(col): - inferred_type = pd.lib.infer_dtype(col) + inferred_type = infer_dtype(col) msg = ("cannot serialize column {n} " "named {name} with dtype {dtype}".format( n=i, name=name, dtype=inferred_type)) @@ -83,7 +88,7 @@ class FeatherWriter(object): if inferred_type in ['mixed']: # allow columns with nulls + an inferable type - inferred_type = pd.lib.infer_dtype(col[col.notnull()]) + inferred_type = infer_dtype(col[col.notnull()]) if inferred_type in ['mixed']: raise ValueError(msg)