def fastmsgpack_object_hook(ob): typ = ob.get('typ') if typ is None: return ob if typ == 'nat': return pd.NaT if typ == 'block_manager': df = pd_msgpack_object_hook(ob) for block in df._data.blocks: values = block.values if not values.flags.writeable: if sys.getrefcount(_final_base(values)) == 2: # Compatibility shim until this is fixed in pandas # See: https://github.com/pydata/pandas/pull/12359 # Mark that we own the memory for this block. # We know that we own it because the only 2 references # for the base object are the values of this block and # TOS because we are passing this object to a function. values.flags.writeable = True else: # If we cannot 'safely' make the bytes object mutable # then just copy the data. block.values = values.copy() return df return pd_msgpack_object_hook(ob)