简体   繁体   中英

TypeError: 'Value' object does not support item assignment

thank you for your help.

I am working with Orange3 (and loving it)... I am aggregating large amounts of data and processing it for normalization, formatting and logical analysis.

I am using python to manipulate data in fields.

Here is a code snip:

new_data = in_data.copy()
        for d in new_data:
        for f in d.domain.attributes:
            #print(f)
            if f.name == "Phone":
                counter+=1

                inan = np.isnan(d["Phone"])
                print("NaN Check: " + str(inan))

                fph = str(phone_format(d["Phone"].value))

                print(str(counter) + ": " + fph)
                d[f]["Phone"]=str(fph)

TypeError: 'Value' object does not support item assignment

This is the offending line of code: d[f]["Phone"]=str(fph)

Will someone kindly advise me of the correct? and pythonic (if possible) way to update the specific field during an iterative investigation?

Thanks in advance!

@objectAntics

Credit goes to @MarkoToplak

If you want to modify values for Orange.data.Table, you will have to set the correct value in your new_data.X, which is 2D numpy table of floats. It can not contain strings. Strings in Orange.data.Table can only be stored as meta attributes. – Marko Toplak 8 hours ago <

@MarkoToplak you were spot on... I had to modify the inputs to be meta/text and reload the file which made assignment possible. THANK YOU! – objectAntics just now Edit Delete

new_data[counter]["Phone"] = fph

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM