Skip to content

Joining DataFrames (or Series) and Series. #5834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jseabold opened this issue Jan 3, 2014 · 5 comments
Closed

Joining DataFrames (or Series) and Series. #5834

jseabold opened this issue Jan 3, 2014 · 5 comments
Labels
API Design Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@jseabold
Copy link
Contributor

jseabold commented Jan 3, 2014

pd.version.version
'0.12.0-1149-g141e93a'

Maybe already fixed, but I'm afraid to upgrade in the middle of working on a project given past experiences.

As I recall there were several ways proposed to join a series to a DataFrame with join being the preferred way.

df = pd.DataFrame(np.random.random((30,2)), columns=["A","B"])
series = pd.Series(np.random.random(30), name="C")

I know I can do

df["C"] = series

or

df = df.join(series)

But it'd be nice if the following also worked given that I'd like to write general code.

pd.concat((df, series), axis=1) # ok error message at least
df.merge(series) # just call join under the hood? bad error message

This is "unexpected" that it somehow tries to append the rows. Looks like a bug to me. Should it take an axis keyword?

df.append(series)
@jreback
Copy link
Contributor

jreback commented Jan 3, 2014

this would need to be implemented (not difficult), and I agree should be done...

@jreback
Copy link
Contributor

jreback commented Jan 3, 2014

work around in 0.13 (to_frame is new)

def f(x):
   if isintance(x, Series):
        return x.to_frame()
   return x

pd.concat([ f(x) for x in list_of_stuff ])

@jorisvandenbossche
Copy link
Member

related #2385?

@jreback
Copy link
Contributor

jreback commented Jan 3, 2014

@jorisvandenbossche definitely...there are a number of condition when this SHOULD raise, but should work otherwise.....need someone to sort them out...

close this issue and put enhancement on the other one?

@jreback
Copy link
Contributor

jreback commented Feb 18, 2014

dup of #2385

@jreback jreback closed this as completed Feb 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

3 participants