-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
handle nan values in DataFrame.update when overwrite=False #15593
Comments
yeah this looks like a bug. So a short-term fix is ok if you'd want to push that. |
@cluoren are you doing it? else I can take it up. I have looked into it already. |
@mayukh18 just created a pull request. thx tho. |
…s-dev#15593 add nan test for DataFrame.update update whatsnew v0.20.2
…as-dev#15593) BUG: handle nan values in DataFrame.update when overwrite=False (pandas-dev#15593) add nan test for DataFrame.update update whatsnew v0.20.2
…as-dev#15593) BUG: handle nan values in DataFrame.update when overwrite=False (pandas-dev#15593) add nan test for DataFrame.update update whatsnew v0.20.2
…as-dev#15593) add nan test for DataFrame.update update whatsnew v0.20.2
…as-dev#15593) add nan test for DataFrame.update update whatsnew v0.20.2
…as-dev#15593) add nan test for DataFrame.update update whatsnew v0.20.2
…as-dev#15593) add nan test for DataFrame.update update whatsnew v0.20.2
…as-dev#15593) (pandas-dev#16430) (cherry picked from commit 85080aa)
The issue with NaN seems to be fixed in v0.20.2, but a similar problem still exists with NaT if it exists anywhere in the dataframe.
|
@olizhu could you search to see if we have an issue for that already (I don't recall seeing it before). If not, could you open a new issue for it? |
Code Sample
Problem description
I got TypeError: invalid type promotion error when updating a DF with a datetime column. The 2nd DF doesn't have this column. The error message is in the details (although bad formatted).
IMHO, the culpit is in the DataFrame.update. The block checking
mask.all
should be outside theif
block and applies to the caseoverwrite=False
as well.C:\Users\pcluo\Anaconda3\lib\site-packages\pandas\core\frame.py in update(self, other, join, overwrite, filter_func, raise_conflict)
3845
3846 self[col] = expressions.where(mask, this, that,
-> 3847 raise_on_error=True)
3848
3849 # ----------------------------------------------------------------------
C:\Users\pcluo\Anaconda3\lib\site-packages\pandas\computation\expressions.py in where(cond, a, b, raise_on_error, use_numexpr)
228
229 if use_numexpr:
--> 230 return _where(cond, a, b, raise_on_error=raise_on_error)
231 return _where_standard(cond, a, b, raise_on_error=raise_on_error)
232
C:\Users\pcluo\Anaconda3\lib\site-packages\pandas\computation\expressions.py in _where_numexpr(cond, a, b, raise_on_error)
151
152 if result is None:
--> 153 result = _where_standard(cond, a, b, raise_on_error)
154
155 return result
C:\Users\pcluo\Anaconda3\lib\site-packages\pandas\computation\expressions.py in _where_standard(cond, a, b, raise_on_error)
126 def _where_standard(cond, a, b, raise_on_error=True):
127 return np.where(_values_from_object(cond), _values_from_object(a),
--> 128 _values_from_object(b))
129
130
TypeError: invalid type promotion
The text was updated successfully, but these errors were encountered: