Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in summary.pandas_frame #1028

Closed
eivindjahren opened this issue Dec 3, 2024 · 1 comment · Fixed by #1030
Closed

Bug in summary.pandas_frame #1028

eivindjahren opened this issue Dec 3, 2024 · 1 comment · Fixed by #1030
Assignees
Labels

Comments

@eivindjahren
Copy link
Collaborator

eivindjahren commented Dec 3, 2024

Put the following code in a test.py:

from resdata.summary import Summary

smry = Summary("test-data/local/ECLIPSE/cp_simple3/SHORT.UNSMRY")
smry.pandas_frame(time_index=smry.time_range(interval="1Y"), column_keys=["WELL:NAME"])

With pandas 2.0 you get the following exception:

Traceback (most recent call last):
  File "<string>", line 17, in __PYTHON_EL_eval
  File "test.py", line 9, in <module>
    df = smry.pandas_frame(time_index=yearly_dates, column_keys=["GGPT:NNA"])
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/resdata/summary/rd_sum.py", line 618, in pandas_frame
    frame = pd.DataFrame(index=time_index, columns=list(keywords), data=data)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/pandas/core/frame.py", line 827, in _init_
    mgr = ndarray_to_mgr(
          ^^^^^^^^^^^^^^^
  File ".../site-packages/pandas/core/internals/construction.py", line 332, in ndarray_to_mgr
    index, columns = _get_axes(
                     ^^^^^^^^^^
  File ".../site-packages/pandas/core/internals/construction.py", line 751, in _get_axes
    index = ensure_index(index)
            ^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/pandas/core/indexes/base.py", line 7649, in ensure_index
    return Index(index_like, copy=copy)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/pandas/core/indexes/base.py", line 532, in _new_
    raise cls._raise_scalar_data_error(data)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/pandas/core/indexes/base.py", line 5289, in _raise_scalar_data_error
    raise TypeError(
TypeError: Index(...) must be called with a collection of some kind, TimeVector(size = 21) at 0x5634c5df0b10 was passed
@HakonSohoel
Copy link
Contributor

Cherrypicked improvements from Eivinds PR into my PR

@HakonSohoel HakonSohoel moved this from In Progress to Ready for Review in SCOUT Dec 3, 2024
@eivindjahren eivindjahren moved this from Ready for Review to Reviewed in SCOUT Dec 4, 2024
@HakonSohoel HakonSohoel moved this from Reviewed to Ready for Review in SCOUT Dec 4, 2024
@github-project-automation github-project-automation bot moved this from Ready for Review to Done in SCOUT Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
3 participants