I'm concatenating two pandas DataFrames column-wise (axis=1), with join='inner' like so:
import pandas as pd
print('pd.__version__ = ', pd.__version__)
DF_empty = pd.DataFrame()
DF_a = pd.DataFrame({'a': [1, 2]}, index=[0, 1])
DF_b = pd.DataFrame({'b': [3]}, index=[1])
DF_empty_inner_a = pd.concat([DF_empty, DF_a], axis=1, join='inner')
DF_a_inner_b = pd.concat([DF_a, DF_b], axis=1, join='inner')
print('empty inner a:\n{}\n'.format(DF_empty_inner_a))
print('a inner b:\n{}'.format(DF_a_inner_b))
and I get:
pd.__version__ = 0.19.2
empty inner a:
a
0 1
1 2
a inner b:
a b
1 2 3
but I was expecting that DF_empty_inner_a would be empty.
Is this a bug, a feature, or my misconception?
mergealternative works niceprint (pd.merge(DF_empty, DF_a, left_index=True, right_index=True))Empty DataFrame Columns: [] Index: []either way (forDF_empty = pd.DataFrame(), and forDF_empty = pd.DataFrame(index=[])).