Skip to content

Commit

Permalink
Fix summary.pandas_frame time_index TypeError
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonSohoel committed Dec 3, 2024
1 parent 4f0df4d commit bc377a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/resdata/summary/rd_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def pandas_frame(self, time_index=None, column_keys=None):
data.ctypes.data_as(ctypes.POINTER(ctypes.c_double)),
)

frame = pd.DataFrame(index=time_index, columns=list(keywords), data=data)
frame = pd.DataFrame(index=list(time_index), columns=list(keywords), data=data)
return frame

@staticmethod
Expand Down
12 changes: 12 additions & 0 deletions python/tests/rd_tests/test_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import os
import os.path
import pytest
import shutil
import stat
import datetime
Expand Down Expand Up @@ -756,6 +757,17 @@ def test_resample_extrapolate(self):
rd_sum.get_interp_direct(key_rate, t),
)

def test_pandas2_compatibility_dataframe_index(self):
# regression test to verify that pandas frames in pandas 2
# does not break due to missing collection for time_index
path = os.path.join(self.TESTDATA_ROOT, "local/ECLIPSE/cp_simple3/SHORT.UNSMRY")
smry = Summary(path)
try:
smry.pandas_frame(time_index=smry.time_range(interval="1Y"), column_keys=["WELL:NAME"])
except TypeError as err:
pytest.fail(repr(err))



def test_t_step():
sum = createSummary(
Expand Down

0 comments on commit bc377a6

Please sign in to comment.