diff --git a/python/resdata/grid/rd_grid.py b/python/resdata/grid/rd_grid.py index d20c236a6..65ed70917 100644 --- a/python/resdata/grid/rd_grid.py +++ b/python/resdata/grid/rd_grid.py @@ -1407,9 +1407,9 @@ def export_data(self, index_frame, kw, default=0): if not isinstance(index_frame, pandas.DataFrame): raise TypeError("index_frame must be pandas.DataFrame") if len(kw) == self.get_global_size(): - index = numpy.array(index_frame.index, dtype=numpy.int32) + index = index_frame.index.to_numpy(dtype=numpy.int32, copy=True) elif len(kw) == self.get_num_active(): - index = numpy.array(index_frame["active"], dtype=numpy.int32) + index = index_frame["active"].to_numpy(dtype=numpy.int32, copy=True) else: raise ValueError("The keyword must have a 3D compatible length") @@ -1444,7 +1444,9 @@ def export_volume(self, index_frame): Index_fram must be a pandas dataframe with the same structure as obtained from export_index. """ - index = numpy.array(index_frame.index, dtype=numpy.int32) + if not isinstance(index_frame, pandas.DataFrame): + raise TypeError("index_frame must be pandas.DataFrame") + index = index_frame.index.to_numpy(dtype=numpy.int32, copy=True) data = numpy.zeros(len(index), dtype=numpy.float64) self._export_volume( len(index), @@ -1460,7 +1462,9 @@ def export_position(self, index_frame): Index_fram must be a pandas dataframe with the same structure as obtained from export_index. """ - index = numpy.array(index_frame.index, dtype=numpy.int32) + if not isinstance(index_frame, pandas.DataFrame): + raise TypeError("index_frame must be pandas.DataFrame") + index = index_frame.index.to_numpy(dtype=numpy.int32, copy=True) data = numpy.zeros([len(index), 3], dtype=numpy.float64) self._export_position( len(index), @@ -1504,7 +1508,9 @@ def export_corners(self, index_frame): increase 'towards the sky'; the safest way is probably to check this explicitly if it matters for the case at hand. """ - index = numpy.array(index_frame.index, dtype=numpy.int32) + if not isinstance(index_frame, pandas.DataFrame): + raise TypeError("index_frame must be pandas.DataFrame") + index = index_frame.index.to_numpy(dtype=numpy.int32, copy=True) data = numpy.zeros([len(index), 24], dtype=numpy.float64) self._export_corners( len(index),