Skip to content

ERR: ValueError when merging on incompatible dtypes #18674

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

Merged
merged 3 commits into from
Dec 10, 2017

Conversation

reidy-p
Copy link
Contributor

@reidy-p reidy-p commented Dec 6, 2017

@pep8speaks
Copy link

pep8speaks commented Dec 6, 2017

Hello @reidy-p! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on December 09, 2017 at 15:46 Hours UTC

@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Error Reporting Incorrect or improved errors from pandas Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Dec 7, 2017

# Check if we are trying to merge on obviously
# incompatible dtypes GH 9780
msg = ("You are trying to merge on {lk_dtype} and "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you do these as separate elif (rather than catch these on the big else, which should be just for the object type)

left = df
for col in df.columns:
right = DataFrame({'A': df[col]})
result = pd.merge(left, right, on='A')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you parameterize this test

@codecov
Copy link

codecov bot commented Dec 7, 2017

Codecov Report

Merging #18674 into master will decrease coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18674      +/-   ##
==========================================
- Coverage    91.6%   91.56%   -0.05%     
==========================================
  Files         153      153              
  Lines       51273    51285      +12     
==========================================
- Hits        46970    46957      -13     
- Misses       4303     4328      +25
Flag Coverage Δ
#multiple 89.42% <100%> (-0.03%) ⬇️
#single 40.67% <0%> (-0.12%) ⬇️
Impacted Files Coverage Δ
pandas/core/reshape/merge.py 94.2% <100%> (-0.21%) ⬇️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/plotting/_converter.py 64.78% <0%> (-1.74%) ⬇️
pandas/util/testing.py 81.82% <0%> (-0.2%) ⬇️
pandas/core/frame.py 97.81% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 86606b2...0ca53a5. Read the comment docs.

@reidy-p reidy-p force-pushed the merge_incompat_dtypes branch from d531ac5 to 0e9a975 Compare December 7, 2017 10:44
@jreback jreback added this to the 0.22.0 milestone Dec 7, 2017
@jreback
Copy link
Contributor

jreback commented Dec 7, 2017

rebase and looks good to go.

@reidy-p reidy-p force-pushed the merge_incompat_dtypes branch from 0e9a975 to ba5aa95 Compare December 7, 2017 11:31
@@ -186,6 +186,8 @@ Other API Changes
- :func:`Series.fillna` now raises a ``TypeError`` instead of a ``ValueError`` when passed a list, tuple or DataFrame as a ``value`` (:issue:`18293`)
- :func:`pandas.DataFrame.merge` no longer casts a ``float`` column to ``object`` when merging on ``int`` and ``float`` columns (:issue:`16572`)
- The default NA value for :class:`UInt64Index` has changed from 0 to ``NaN``, which impacts methods that mask with NA, such as ``UInt64Index.where()`` (:issue:`18398`)
- Building pandas for development now requires ``cython >= 0.24`` (:issue:`18613`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm this moved, can you fixup

@reidy-p reidy-p force-pushed the merge_incompat_dtypes branch 2 times, most recently from fa306e4 to cc03f5a Compare December 8, 2017 14:15
@reidy-p reidy-p force-pushed the merge_incompat_dtypes branch from cc03f5a to 0ca53a5 Compare December 9, 2017 15:46
@jreback jreback merged commit 1355df6 into pandas-dev:master Dec 10, 2017
@jreback
Copy link
Contributor

jreback commented Dec 10, 2017

thanks @reidy-p

@inodb
Copy link

inodb commented Dec 10, 2017

Thanks for the fix @reidy-p and @jreback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Error Reporting Incorrect or improved errors from pandas Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pd.merge() doesn't merge int and str column dtypes but no warning or error
4 participants