-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix issue with datetime[ns, tz] input in Block.setitem GH32395 #32479
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
Conversation
# Conflicts: # pandas/tests/indexing/test_loc.py
#29334 might actually fix this (or if not is a bit cleaner) |
#29334 doesn't quite seem to fix this (some of the new tests here fail on that branch). |
FYI, I'm currently planning to push this to the next release. |
Any thoughts on - #32479 (comment)? |
I've been working on Block.setitem, will see if I can find a nice option that doesnt entail reverting #29139. |
# Conflicts: # doc/source/whatsnew/v1.0.2.rst # pandas/tests/indexing/test_loc.py
@simonjayhawkins I have updated this, please look at alternate solutions discussed in #32479 (comment) and #32479 (comment) if one of those is preferred I will push another update. @jbrockmendel let me know if there is an update on this. |
@h-vishal the thing to do here is to add a clause into
Then update the tests to use tm.assert_series_equal and tm.assert_frame_equal as others have suggested. caveat 1: i havent run the whole test suite on this yet |
@jbrockmendel this will create a column with the corresponding Would it be better to use |
pandas/tests/indexing/test_loc.py
Outdated
s2 = pd.Series(index=s1.index, dtype="object", name="data") | ||
expected = pd.Series( | ||
[ | ||
*pd.date_range("2020-01-01", "2020-01-03", 3, tz=timezone.utc), |
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.
why the "*"
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 guess do
dti = pd.date_range("2020-01-01", "2020-01-03", periods=6, tz=timezone.utc)
expected = pd.Series(dti)
expected[-3:] = pd.NaT
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.
@jbrockmendel okay, if that is preferred.
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.
@jbrockmendel please note the object
dtype
for the result of a slice assignement
does this PR fix the newly found bug? |
@jbrockmendel no, it's unrelated, confirmed in version 0.25 as well, better to create a new issue for it. |
tests.computation.test_eval.check_alignment()" This reverts commit 8cfa045
doc/source/whatsnew/v1.0.4.rst
Outdated
@@ -0,0 +1,28 @@ | |||
|
|||
.. _whatsnew_104: |
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.
pls remove this and all references to 1.0.4, just put a note in 1.1
doc/source/whatsnew/index.rst
Outdated
@@ -24,6 +24,7 @@ Version 1.0 | |||
.. toctree:: | |||
:maxdepth: 2 | |||
|
|||
v1.0.4 |
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.
revert this
doc/source/whatsnew/v1.0.3.rst
Outdated
@@ -26,4 +26,4 @@ Bug fixes | |||
Contributors | |||
~~~~~~~~~~~~ | |||
|
|||
.. contributors:: v1.0.2..v1.0.3|HEAD | |||
.. contributors:: v1.0.2..v1.0.3 |
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.
revert this
pandas/tests/indexing/test_loc.py
Outdated
|
||
|
||
def test_loc_setitem_df_datetime64tz_full_column_with_index(): | ||
df = pd.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.
add a comment with the issue number
pandas/tests/indexing/test_loc.py
Outdated
df = pd.DataFrame( | ||
pd.date_range("2020-01-01", "2020-01-06", 6, tz=timezone.utc), columns=["data"] | ||
) | ||
df2 = pd.DataFrame(index=df.index) |
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.
use
result =
expected =
as its not really clear what you are comparing here
pandas/tests/indexing/test_loc.py
Outdated
|
||
|
||
def test_loc_setitem_df_datetime64tz_slice(): | ||
df = pd.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.
add the issue number as a comment
pandas/tests/indexing/test_loc.py
Outdated
columns=["data"], | ||
dtype="object", | ||
) | ||
df2.loc[df.index[:3], "data"] = df["data"][:3] |
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.
use
result =
expected =
pandas/tests/indexing/test_loc.py
Outdated
tm.assert_frame_equal(df2, expected) | ||
|
||
|
||
def test_loc_setitem_df_datetime64tz_column_without_index(): |
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.
you don't need to repeat things like this, instead we aleady have generic tests in : pandas/tests/extension//base/setitem.py
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.
@h-vishal this is the key comment. Please do not repeat things like this. We already have fixtures for all of these.
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.
@jreback I have pushed a commit with the requested changes.
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 doesn't look like anything has changed. there should be NO tests here, rather in pandas/tests/extension/base/setitem
# Conflicts: # doc/source/whatsnew/v1.1.0.rst
pandas/tests/indexing/test_loc.py
Outdated
@@ -1106,3 +1107,133 @@ def test_loc_with_period_index_indexer(): | |||
tm.assert_frame_equal(df, df.loc[list(idx)]) | |||
tm.assert_frame_equal(df.iloc[0:5], df.loc[idx[0:5]]) | |||
tm.assert_frame_equal(df, df.loc[list(idx)]) | |||
|
|||
|
|||
def test_loc_setitem_df_datetime64tz_full_column_with_index(): |
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.
all of this need to move to pandas/tests/extension/setitem
BUT you need to use the fixtures, so you are like writing ONE test.
@h-vishal can you rebase and address comments |
thanks @h-vishal |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free to suggest an improvement. |
…etime[ns, tz] input in Block.setitem)
…tz] input in Block.setitem) (#34369) Co-authored-by: h-vishal <[email protected]> Co-authored-by: jbrockmendel <[email protected]>
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff