8000 fix: scalar timestamp assignment (#19843) by DylanDmitri · Pull Request #19973 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

fix: scalar timestamp assignment (#19843) #19973

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 7 commits into from
Aug 2, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
issue number in tests
  • Loading branch information
DylanDmitri committed Mar 2, 2018
commit 33f865129a9cfc3aa4ecba4b5a5f2b5e531b4178
6 changes: 2 additions & 4 deletions pandas/tests/frame/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3045,19 +3045,17 @@ def test_transpose(self):
assert_frame_equal(result, expected)

def test_scalar_assignment(self):
Copy link
Member

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.

# issue #19843
df = pd.DataFrame(index=(0, 1, 2))

df['now'] = pd.Timestamp('20130101', tz='UTC')

assert isinstance(df.dtypes[0], DatetimeTZDtype)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

construct the expected frame and use assert_frame_equal

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this in class TestDataFrameIndexingDatetimeWithTZ(TestData)

name it test_setitem_scalar

parameterize it with both a tz and a tz-aware value.


def test_datetime_index_assignment(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a duplicate test.

Copy link
Contributor

Choose a reason for hiding this comment

The 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)

# issue #19843
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)


Expand Down
0