Skip to content

DASware5Parser.parse raises ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all() #9

@L-kuehl

Description

@L-kuehl

Hi, when parsing my v5 file, an ValueError is raised by the function DASware5Parser.parse().
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()


ValueError Traceback (most recent call last)
/Users/01_Basic_Use.ipynb Cell 4 in <cell line: 6>()
3 import ipywidgets
5 import detl
----> 6 ddata = detl.parse('v5_Control_1_.csv')
8 # display what the ddata object looks like
9 ddata

File ~/opt/anaconda3/lib/python3.9/site-packages/detl/init.py:61, in parse(filepath, inoculation_times)
46 """Parses a raw DASware CSV file into a DWData object.
47
48 Args:
(...)
58 NotImlementedError: when the file contents do not match with a known DASware CSV style
59 """
60 parser = get_parser(filepath)
---> 61 data = parser.parse(filepath)
63 if inoculation_times:
64 for r, dt_inoculate in inoculation_times.items():

File ~/opt/anaconda3/lib/python3.9/site-packages/detl/parsing/dw5.py:137, in DASware5Parser.parse(self, filepath)
134 dd = common.transform_to_dwdata(scoped_blocks, BLOCKPARSERS, version=core.DASwareVersion.V5)
136 for _, reactor in dd.items():
--> 137 reactor._dataframe = common.transform_trackdata(reactor.trackdata, columnmapping, core.DASwareVersion.V5)
...
1528 f"The truth value of a {type(self).name} is ambiguous. "
1529 "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
1530 )

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

As far as I could see, the error is produced in common.py in transform_trackdata()

    for key, reg in columnmapping.items():
        new_data = trackdata.filter(regex=reg, axis="columns").squeeze()
        if (not new_data.empty) & (not new_data.isnull().all()):
            transformed_data.loc[:, key] = new_data
            
    transformed_data = transformed_data.fillna(method="ffill")

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions