I'm working on a data frame that has one hot encoded columns. For simplicity, let's say it looks like this:

```
    a   b
0   1 NaN
1   1   1
2   1 NaN
3 NaN   1

```

I want to replace the last available value with NaN. I'm getting the last available index location with

```
df.apply(pd.Series.last_valid_index)

Out[6]:
a    2
b    3

```

So using that, I wanted to use

```
df.replace(df.apply(pd.Series.last_valid_index), np.nan)

```

This doesn't seem to replace the last valid index cell with NaN. Does anyone have a good idea of how to replace the last value with NaN or any other value. Thanks!