I'm new to Python and Pandas and I'm trying to replace all null values in an array with a specific value.
Everytime I run this, the updated values don't persist.
I've seen that Pandas doesn't save changes when iterating rows...so how CAN I save the changes?
Here is my code
animal_kinds = set(df.AnimalKind) # this gives categories used below in the "ak" like dog, cat, bird
new_color_dog = 'polka dots'
new_color_cat = 'plaid'
new_color_bird = 'stripes'
for ak in animal_kinds:
ak_colors = ak['colors']
ak_with_no_color = animals[(df["Kind"] == ak ) & (df["Color"] == "" ) ]
result_count = len(ak_with_no_color)
if result_count:
ak_with_no_color.at["Color"] = new_color_ak #sets new color based on kind of animal (ak)
print(str(ak) 'color is changed to ' + str(new_color_ak))