Conditionally replace values in pandas dataframe – numpy where behaviour

My goal is to replace certain values in a pandas dataframe, based on a condition.

I have discovered that the numpy where method expects the first argument to be an array of boolean values, and the following works:

def evaluate_array(array_to_evaluate):
    output_array = []
    for elem in array_to_evaluate:
        if elem is None:
    return output_array

df['property'] = np.where(
    'The value is None',


There must be a better way to express the lines of code above! I have tried the following:

df.loc[ is None, 'property'] = 'None'

but I get the error:

KeyError: 'cannot use a single bool to index into setitem'

the accepted solution to which is as long winded as my own working code!

EDIT: A great solution offered in the comments below works for my situation as follows:

df = df.fillna(value={'property':'The value is None'})

or even more readable:

df['property'].fillna('The value is None', inplace=True)

EDIT2: Also, please see the accepted answer below for another great solution


How about

>>> df['property'] = df['property'].fillna('The value is None')

Or alternatively, if None is str you can simply do replace:

>>> df['property'] = df['property'].replace('None','The value is None')