-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Treat Series as 1-column dataframe in concat with dataframe #15047
Comments
https://github.com/pandas-dev/pandas/blob/master/pandas/tools/merge.py#L1580 is the reason this ends up 0, but I don't remember why that is. Will mark this as a bug. |
+1 for resulting in out[13] rather than error. |
Looks like with a recent commit, the line got bumped. Here's a commit specific link. Looking at the current logic (and trying it out), it seems that this is definitely a bug instead of a difference in expectations - since the series is always interpreted as a frame with name In [23]: df = pd.DataFrame({'x': range(5), 'y': range(5), 0: range(5)})
In [24]: pd.concat([df, df.x])
/Users/jcrist/anaconda/envs/dask/lib/python3.5/site-packages/pandas/indexes/api.py:71: RuntimeWarning: unorderable types: str() > int(), sort order is undefined for incomparable objects
result = result.union(other)
Out[24]:
x 0 y
0 0.0 0 0.0
1 1.0 1 1.0
2 2.0 2 2.0
3 3.0 3 3.0
4 4.0 4 4.0
0 NaN 0 NaN
1 NaN 1 NaN
2 NaN 2 NaN
3 NaN 3 NaN
4 NaN 4 NaN |
Looked into a little, and found current behavior is to replace empty |
I'm guessing that That specific code happens right after the code for pandas/pandas/core/reshape/concat.py Lines 603 to 610 in fce7760
(Note: |
take |
When concatenating a dataframe and series along axis 1, the docs indicate that the series will be treated as a series with a single column matching the column name. Based on this, I'd expect similar behavior (or an error) when concatenating a named series with a dataframe along axis 0. However, this seems to result in a new numeric column for the named series instead of converting the series to a dataframe:
I'd expect either an error, or the behavior in out[13].
The text was updated successfully, but these errors were encountered: