Pandas version 0.18.1:
In[1]: import pandas as pd
In[2]: df = pd.DataFrame(np.array([[1., 2.], [3., 4.]]), columns=list('AB'))
In[3]: ts = pd.Series([5., 6., 7.])
In[4]: df.align(ts, join='outer', axis=0, broadcast_axis=1)
Out[4]:
( A B
0 1.0 2.0
1 3.0 4.0, A B
0 5.0 5.0
1 6.0 6.0)
However, as 'join' is specified to be 'outer', I would have expected the following result:
Out[4]:
( A B
0 1.0 2.0
1 3.0 4.0
2 NaN NaN, A B
0 5.0 5.0
1 6.0 6.0
2 7.0 7.0
dtype: float64)
Same problem occurs for:
df.align(ts, join='right', axis=0, broadcast_axis=1)
ts.align(df, join='outer', axis=0, broadcast_axis=1)
ts.align(df, join='left', axis=0, broadcast_axis=1)
Comment From: jreback
yeah this has very little testing. I'll mark it as a bug; seems like an easy fix if you'd like to take a crack at it.
Comment From: kdebrab
The easy fix seems to replace in generic.py:
**other._construct_axes_dict()
by **self._construct_axes_dict(**other._construct_axes_dict(axes=['columns']))
and
**self._construct_axes_dict()
by **other._construct_axes_dict(**self._construct_axes_dict(axes=['columns']))
However, looking at the code I see another issue: though the documentation mentions as possible values for broadcast_axis: {0, 1, ‘index’, ‘columns’}, in reality only broadcast_axis == 1
has been implemented!
Unfortunately, I don't have the time now to implement that myself. I hope someone else will take this up...
Comment From: pfrcks
Hi @jreback @kdebrab I would like to work on this as my first fix if that's not a problem?
Comment From: jbrockmendel
broadcast_axis deprecated in #51856, closing.