-
-
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
fix: scalar timestamp assignment (#19843) #19973
Changes from 1 commit
5a9b1b9
601cf54
33f8651
59069b9
edcb4e2
c48fbe9
1b9649c
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 |
---|---|---|
|
@@ -37,6 +37,8 @@ | |
|
||
from pandas.tests.frame.common import TestData | ||
|
||
from pandas.core.dtypes.dtypes import DatetimeTZDtype | ||
|
||
|
||
class TestDataFrameIndexing(TestData): | ||
|
||
|
@@ -3042,6 +3044,22 @@ def test_transpose(self): | |
expected.index = ['A', 'B'] | ||
assert_frame_equal(result, expected) | ||
|
||
def test_scalar_assignment(self): | ||
df = pd.DataFrame(index=(0, 1, 2)) | ||
|
||
df['now'] = pd.Timestamp('20130101', tz='UTC') | ||
|
||
assert isinstance(df.dtypes[0], DatetimeTZDtype) | ||
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. construct the expected frame and use 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. put this in name it parameterize it with both a tz and a tz-aware value. |
||
|
||
def test_datetime_index_assignment(self): | ||
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. this is a duplicate test. 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. you could put it as an additional test in the class as above if you'd like (parametrize as well) |
||
df = pd.DataFrame(index=(0, 1, 2)) | ||
|
||
di = pd.DatetimeIndex( | ||
[pd.Timestamp('20130101', tz='UTC')]).repeat(len(df)) | ||
df['now'] = di | ||
|
||
assert isinstance(df.dtypes[0], DatetimeTZDtype) | ||
|
||
|
||
class TestDataFrameIndexingUInt64(TestData): | ||
|
||
|
This file was deleted.
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.
Reference issue number for both tests.