-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: update should try harder to preserve dtypes #4094 #40219
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
Changes from 3 commits
2dc75cc
a2109bb
da88edf
5bf17b5
62d8b0e
7386a1f
3cc53af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6939,6 +6939,7 @@ def update( | |
if not isinstance(other, DataFrame): | ||
other = DataFrame(other) | ||
|
||
other_dtypes = other.dtypes # dtype might change during reindexing | ||
Horstage marked this conversation as resolved.
Show resolved
Hide resolved
|
||
other = other.reindex_like(self) | ||
|
||
for col in self.columns: | ||
|
@@ -6963,7 +6964,11 @@ def update( | |
if mask.all(): | ||
continue | ||
|
||
self[col] = expressions.where(mask, this, that) | ||
col_array = expressions.where(mask, this, that) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what are you trying to do here? infer and cast? this is very awkward what you are doing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Example:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reindex_like is called here: https://github.com/pandas-dev/pandas/pull/40219/files#diff-421998af5fe0fbc54b35773ce9b6289cae3e8ae607f81783af04ebf1fbcaf077R6943 to have the same index in the other as in self, but for missing indices it inserts NANs and changes data type, maybe reindex_like needs to be changed in this case... |
||
if self[col].dtype == other_dtypes[col] != col_array.dtype: | ||
self[col] = Series(col_array, index=self.index, dtype=self[col].dtype) | ||
else: | ||
self[col] = col_array | ||
|
||
# ---------------------------------------------------------------------- | ||
# Data reshaping | ||
|
Uh oh!
There was an error while loading. Please reload this page.