-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
Milestone
Description
In [3]: df = pd.DataFrame(np.random.randn(5, 5))
In [4]: s = pd.Series(range(5))
In [5]: df.where(df.isnull(), s, axis=0)
Out[5]:
0 1 2 3 4
0 0 1 2 3 4
1 0 1 2 3 4
2 0 1 2 3 4
3 0 1 2 3 4
4 0 1 2 3 4
In [6]: df.where(df.isnull(), s, axis=1)
Out[6]:
0 1 2 3 4
0 0 1 2 3 4
1 0 1 2 3 4
2 0 1 2 3 4
3 0 1 2 3 4
4 0 1 2 3 4
The right axis is used when aligning indices, but it's not used when broadcasting the aligned Series. You also get the right result if the DataFrame is not square, because core.internals.where will transpose if necessary to the get the dimensions to fit.