Meaning of n
First of all, the n
in n-1
refers to the number of dimensions in each of the dataframes, not the number of dataframes. You can see that from the source code at lines 938ff:
def _get_new_axes(self):
ndim = self._get_result_dim()
new_axes = [None] * ndim
if self.join_axes is None:
for i in range(ndim):
if i == self.axis:
continue
new_axes[i] = self._get_comb_axis(i)
else:
if len(self.join_axes) != ndim - 1:
raise AssertionError("length of join_axes must not be "
"equal to {0}".format(ndim - 1))
(Therefore, it should really not read n-1
in the documentation. I guess this formulation is based on the common use example where the index passed with join_axes
is that of one of the dataframes. The passed index could, though, also be a new, synthetic one.)
Use of join_axes
The actual use join_axes
is to replace the indexes of the dataframes that you want to concatenate with a different one (or actually one per dimension).
In this process, the values in each dataframe are simply assigned to the new indices, ignoring the index it contains. Furthermore, if one of the dataframes is longer (in any dimension) than the corresponding index, it will simply be truncated.
Merging time series into one dataframe
What you might be trying to achieve is to combine a bunch of Series
into a DataFrame
and preserve their original (partially) non-matching indices.
pandas.concat([df1,..,dfn], axis=1, join='outer')
does that (with join=outer
).
(However, when you want to plot the resulting dataframe, you might need to find a workaround, because all columns are interrupted by NaNs.)