Skip to content

BUG: empty Series concat has no effect #11082

Closed
@sinhrks

Description

@sinhrks
import numpy as np
import pandas as pd

s1 = pd.Series([1, 2, 3], name='x')
s2 = pd.Series(name='y')

# NG, no columns is added
pd.concat([s1, s2], axis=1)
#    x
#0  1
#1  2
#2  3

# If padded by value, OK
pd.concat([s1, pd.Series([np.nan]*3, name='z')], axis=1)
#    x   z
#0  1 NaN
#1  2 NaN
#2  3 NaN

# If converted to frame, OK.
pd.concat([s1.to_frame(), s2.to_frame()], axis=1)
#    x   y
#0  1 NaN
#1  2 NaN
#2  3 NaN

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions