diff --git a/lib/iris/pandas.py b/lib/iris/pandas.py index 67a651a42a..26ce5c5432 100644 --- a/lib/iris/pandas.py +++ b/lib/iris/pandas.py @@ -1,4 +1,4 @@ -# (C) British Crown Copyright 2013 - 2015, Met Office +# (C) British Crown Copyright 2013 - 2016, Met Office # # This file is part of Iris. # @@ -129,6 +129,15 @@ def _assert_shared(np_obj, pandas_obj): base = pandas_obj.base else: base = pandas_obj[0].base + + # Prior to Pandas 0.17, when pandas_obj is a Series, pandas_obj.values + # returns a view of the underlying array, and pandas_obj.base, which calls + # pandas_obj.values.base, returns the underlying array. In 0.17 and 0.18 + # pandas_obj.values returns the underlying array, so base may be None even + # if the array is shared. + if base is None: + base = pandas_obj.values + # Chase the stack of NumPy `base` references back to see if any of # them are our original array. while base is not None: