I would like to update the value of a cell that takes a list with a new updated list. However, when I try to replace the value using .iloc
I get a ValueError
.
d = {'title':['GrownUps', 'Toy Story', 'Toy Story', 'Avatar', 'Avatar', 'Avatar'], 'year': [["Hello", "World"],
["Not", "Object", "!"],
1995, 2000, 2005, 2006]}
dataset_SO=pd.DataFrame(d)
dataset_SO.iloc[0,1]=["hi", "cat", "dog"] #this line produces the ValueError
ValueError: Must have equal len keys and value when setting with an iterable
I know it might be a silly question, however trying to make this ["hi", "cat", "dog"]
an object, like np.object0(["hi", "cat", "dog"])
. Or this question didn't help me to solve my issue.
Here is a guide as to how to update packages in python
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.