>>> df_copy = df.copy() >>> df_copy.iloc[0, 0] = pd.NA >>> df_copy.map(lambda x: len(str(x)), na_action='ignore') 0 1 0 NaN 4 1 5.0 5 Note that a vectorized version of `func` often exists, which will be much faster. You could square each number elementwise. >>> df.map(lambda x: x**2) 0 1 0 1.000000 4.494400 1 11.262736 20.857489 But it's better to avoid map in that case. >>> df ** 2 0 1 0 1.000000 4.494400 1 11.262736 20.857489 >