-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Concatentation of TZ-aware dataframes (#12396) (#18447) #19327
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 all commits
155fc90
cf618db
9ccb8e7
49eefd7
2f58bc9
4323f5e
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 |
---|---|---|
|
@@ -2183,17 +2183,19 @@ def _assert_take_fillable(self, values, indices, allow_fill=True, | |
fill_value=None, na_value=np.nan): | ||
""" Internal method to handle NA filling of take """ | ||
indices = _ensure_platform_int(indices) | ||
|
||
# only fill if we are passing a non-None fill_value | ||
if allow_fill and fill_value is not None: | ||
if (indices < -1).any(): | ||
msg = ('When allow_fill=True and fill_value is not None, ' | ||
'all indices must be >= -1') | ||
raise ValueError(msg) | ||
taken = values.take(indices) | ||
mask = indices == -1 | ||
if mask.any(): | ||
taken[mask] = na_value | ||
if mask.all(): | ||
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. can add a comment here. is this hit by the tests? |
||
taken = np.full(indices.shape, fill_value=na_value) | ||
else: | ||
taken = values.take(indices) | ||
if mask.any(): | ||
taken[mask] = na_value | ||
else: | ||
taken = values.take(indices) | ||
return taken | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5835,8 +5835,10 @@ def get_reindexed_values(self, empty_dtype, upcasted_na): | |
if len(values) and values[0] is None: | ||
fill_value = None | ||
|
||
if getattr(self.block, 'is_datetimetz', False): | ||
pass | ||
if getattr(self.block, 'is_datetimetz', False) or \ | ||
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. so I would like to fix this more generally. define something like this on the Block. This should just work generally
if can get this to work , then can clean up a bunch of additional code. 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. Not sure how this simplifies. Won't you have to cast the result to the 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 would this do for non-NA holding blocks? Raise a TypeError probably? IOW, what's more important: that you know you'll get a result, or that you know the result will be the same block type? I'd vote for same block type. 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. And should we pass through 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. Actually, perhaps something like
Then you get back a block for This solves two problems:
|
||
is_datetimetz(empty_dtype): | ||
missing_arr = np.full(np.prod(self.shape), fill_value) | ||
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. move this logic to the Block as I indicated above. |
||
return DatetimeIndex(missing_arr, dtype=empty_dtype) | ||
elif getattr(self.block, 'is_categorical', False): | ||
pass | ||
elif getattr(self.block, 'is_sparse', False): | ||
|
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.
@TomAugspurger did we move the empty check into
take
(the new helper)?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.
Yeah,
algos.take
simplifies this. The only thing it doesn't do is the check on lines 2174-2178, where we raise a ValueError whenwhich seems like a strange set of conditions. Going to see what triggers it.