First of all, you have to do:
newIndex, indexer = a.reindex(b)
reindex
returns two things. You need/want to get only the indexer.
So now you can get what you want:
indexerWithNan = np.where(indexer == -1, np.nan, indexer)
Why was your initial code wrong? The reindex()
method does not support the fill_value
parameter for pandas.Index
objects as it does for pandas.Series
or pandas.DataFrame
.