Skip to content

uproot 5.6.8 fails to write simplest pandas DataFrames as root files #1523

@VukanJ

Description

@VukanJ

Dear uproot developers, uproot seems to have suddenly lost its ability to save pandas data frames as root files. Previous versions of uproot5 can do this.

>>> import uproot
>>> uproot.__version__

uproot 5.6.8

Example

import uproot 
import pandas 

df = pandas.DataFrame({"a" : [1,2,3], "b" : [4,5,6]})

with uproot.recreate("file.root") as f:
    f["mytree"] = df

Error:

Traceback (most recent call last):
  File "/projectpath/debug/test.py", line 9, in <module>
    f["mytree"] = df
    ~^^^^^^^^^^
  File "/envpath/envs/py/lib/python3.13/site-packages/uproot/writing/writable.py", line 986, in __setitem__
    self.update({where: what})
    ~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/envpath/envs/py/lib/python3.13/site-packages/uproot/writing/writable.py", line 1598, in update
    uproot.writing.identify.add_to_directory(v, name, directory, streamers)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/envpath/envs/py/lib/python3.13/site-packages/uproot/writing/identify.py", line 57, in add_to_directory
    obj = uproot.writing.writable._regularize_input_type(obj)
  File "/envpath/envs/py/lib/python3.13/site-packages/uproot/writing/writable.py", line 2227, in _regularize_input_type
    obj = uproot.writing._cascadetree.dataframe_to_dict(obj)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'uproot.writing' has no attribute '_cascadetree'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThe problem described is something that must be fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions