Skip to content Skip to sidebar Skip to footer

Unable To Update Specific Entries In A Dataframe

I have a dataframe where some entries in column_1 have NaN values. I want to replace these by the corresponding values in column_2. Both columns hold float64 values. I tried the fo

Solution 1:

This is an example of chained indexing. For getting values, this is generally ok; however for setting values, it may or may not work as you may be trying to set values on a copy. It is always better to set via the indexers ix/loc for multi-dimensional setting.

In this example, use mydf.loc[ix,'columns_1'] = 45

See here for a more complete explanation.

Post a Comment for "Unable To Update Specific Entries In A Dataframe"