-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Use left._constructor on pd.merge #7737
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
Conversation
sure can u add a test pls (create an object that inherits from DataFrame and use it to confirm that this is correct) |
@jreback Done. |
It would also be nice to mention this in the docs (i.e. that the output type is taken from left, so that |
@jwass this is fine, can you update the docs (and do-string). squash and looks ready. |
@JanSchulz Missed your original comment from a few weeks ago - sorry for the delay here. @jreback squashed and rebased. Let me know if the docs should change somewhere else or should be re-worded. |
@@ -520,7 +521,8 @@ def get_result(self): | |||
axes=[llabels.append(rlabels), join_index], | |||
concat_axis=0, copy=self.copy) | |||
|
|||
result = DataFrame(result_data) | |||
typ = self.left._constructor | |||
result = typ(result_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should prob also have __finalize__
called on it? (I know wasn't in the original and doesn't actually do anything in pandas atm..but)
can you add a note in v0.15.0.txt in API section (and reference this PR number) |
Use the _constructor property when creating the merge/ordered_merge result to preserve the output type. Update test and docs appropriately.
@jreback Yes - added the |
merged via 123a555 thanks! |
Use the _constructor property when creating the merge result to
preserve the output type.
If a GeoPandas
GeoDataFrame
is merged with aDataFrame
, the result is hard-coded to always beDataFrame
GeoPandas Issue #118. We'd like it to returnGeoDataFrame
in these casesThis PR uses
left._constructor
to generate the result type for merge operations.