-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: fix replace_list #27720
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
BUG: fix replace_list #27720
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1029,17 +1029,15 @@ def test_replace_series(self, how, to_key, from_key): | |
|
||
tm.assert_series_equal(result, exp) | ||
|
||
# TODO(jbrockmendel) commented out to only have a single xfail printed | ||
@pytest.mark.xfail( | ||
reason="GH #18376, tzawareness-compat bug in BlockManager.replace_list" | ||
@pytest.mark.parametrize("how", ["dict", "series"]) | ||
@pytest.mark.parametrize( | ||
"to_key", | ||
["timedelta64[ns]", "bool", "object", "complex128", "float64", "int64"], | ||
) | ||
# @pytest.mark.parametrize('how', ['dict', 'series']) | ||
# @pytest.mark.parametrize('to_key', ['timedelta64[ns]', 'bool', 'object', | ||
# 'complex128', 'float64', 'int64']) | ||
# @pytest.mark.parametrize('from_key', ['datetime64[ns, UTC]', | ||
# 'datetime64[ns, US/Eastern]']) | ||
# def test_replace_series_datetime_tz(self, how, to_key, from_key): | ||
def test_replace_series_datetime_tz(self): | ||
@pytest.mark.parametrize( | ||
"from_key", ["datetime64[ns, UTC]", "datetime64[ns, US/Eastern]"] | ||
) | ||
def test_replace_series_datetime_tz(self, how, to_key, from_key): | ||
how = "series" | ||
from_key = "datetime64[ns, US/Eastern]" | ||
to_key = "timedelta64[ns]" | ||
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. should these three assignments not be removed now? |
||
|
@@ -1061,23 +1059,16 @@ def test_replace_series_datetime_tz(self): | |
|
||
tm.assert_series_equal(result, exp) | ||
|
||
# TODO(jreback) commented out to only have a single xfail printed | ||
@pytest.mark.xfail( | ||
reason="different tz, currently mask_missing raises SystemError", strict=False | ||
@pytest.mark.parametrize("how", ["dict", "series"]) | ||
@pytest.mark.parametrize( | ||
"to_key", | ||
["datetime64[ns]", "datetime64[ns, UTC]", "datetime64[ns, US/Eastern]"], | ||
) | ||
# @pytest.mark.parametrize('how', ['dict', 'series']) | ||
# @pytest.mark.parametrize('to_key', [ | ||
# 'datetime64[ns]', 'datetime64[ns, UTC]', | ||
# 'datetime64[ns, US/Eastern]']) | ||
# @pytest.mark.parametrize('from_key', [ | ||
# 'datetime64[ns]', 'datetime64[ns, UTC]', | ||
# 'datetime64[ns, US/Eastern]']) | ||
# def test_replace_series_datetime_datetime(self, how, to_key, from_key): | ||
def test_replace_series_datetime_datetime(self): | ||
how = "dict" | ||
to_key = "datetime64[ns]" | ||
from_key = "datetime64[ns]" | ||
|
||
@pytest.mark.parametrize( | ||
"from_key", | ||
["datetime64[ns]", "datetime64[ns, UTC]", "datetime64[ns, US/Eastern]"], | ||
) | ||
def test_replace_series_datetime_datetime(self, how, to_key, from_key): | ||
index = pd.Index([3, 4], name="xxx") | ||
gfyoung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
obj = pd.Series(self.rep[from_key], index=index, name="yyy") | ||
assert obj.dtype == from_key | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we even need this check any more or would this happen implicitly?
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.
I'm not sure, I was mostly happy about avoiding the use of AXIS_ORDERS.
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.
general question. is NDFrame supposed to represent a n-dimensional data structure or is it a base class for Series and DataFrame?
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.
NDFrame is just a base class (of Series & DataFrame)
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.
it was also backing Panel / Panel4D, but no longer
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.
i'm thinking should the generic nature of NDFrame be maintained to facilitate a third party Panel implementation, or is that ruled out-of-scope for pandas?
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.
no that's out of scope. the reason we removed Panel is because of all of the complexitiy related to > 2ndim. xarray is a better platform for that.
generic is just the collection of common api between Series/DataFrame
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.
mypy complained about FrameOrSeries, was OK with NDFrame
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.
in pandas._typing FrameOrSeries is a typevar of Series and DataFrame. This is not applicable to core.generic.
in #27646 FrameOrSeries is defined as a typevar bound by NDFrame so that a series returns a series, a DataFrame returns a DataFrame, a subclassed DataFrame returns a subclassed DataFrame etc.
NDFrame is a nominal type, so allows any subclass of NDFrame to be returned.