forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: scalar timestamp assignment (pandas-dev#19843)
- Loading branch information
1 parent
a7a7f8c
commit 5a9b1b9
Showing
2 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pandas as pd | ||
from pandas.core.dtypes.dtypes import DatetimeTZDtype | ||
|
||
|
||
# referencing #19843: scalar assignment of a tz-aware is object dtype | ||
|
||
class TestTimestampProperties(object): | ||
|
||
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) | ||
|
||
def test_datetime_index_assignment(self): | ||
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) |