Skip to content

BUG: Preserve timezone in unaligned assignments #12982

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

Closed

Conversation

ajenkins-cargometrics
Copy link
Contributor

@ajenkins-cargometrics ajenkins-cargometrics commented Apr 25, 2016

A fix for #12981. When doing a slice assign to a DataFrame where the
right-hand-side was timezone-aware datetime Series which required
realignment to perform the assignment, the timezone would be stripped
from the RHS on assignment.

@@ -1940,6 +1940,16 @@ def test_setitem_with_unaligned_sparse_value(self):
exp = pd.Series([1, 0, 0], name='new_column')
assert_series_equal(df['new_column'], exp)

def test_setitem_with_unaligned_tz_aware_datetime_column(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also test this will .loc and a mask

e.g.

df.loc[[0,1,2],'dates'] = columns[[1,0,2]] (should be the same result)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've addressed comments, and travis checks pass.

@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves Timezones Timezone data dtype labels Apr 25, 2016
@jreback jreback added this to the 0.18.1 milestone Apr 25, 2016
@@ -428,3 +428,4 @@ Bug Fixes


- Bug in ``fill_value`` is ignored if the argument to a binary operator is a constant (:issue `12723`)
- Bug in ``DataFrame._santize_column`` now preserves Timezone when RHS is a Series (:issue `12981`)
Copy link
Contributor

Choose a reason for hiding this comment

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

say setting a column with alignment to a Series that is datetime tz-aware dtype. We don't expect readers to know about internal functions, just the outward effects.

@jreback
Copy link
Contributor

jreback commented Apr 25, 2016

minor changes. ping when green.

- ``pd.read_excel()`` now accepts column names associated with keyword argument ``names``(:issue:`12870`)


- Bug in ``fill_value`` is ignored if the argument to a binary operator is a constant (:issue `12723`)
Copy link
Member

Choose a reason for hiding this comment

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

Pls remove this.

A fix for GH12981.  When doing a slice assign to a DataFrame where the
right-hand-side was timezone-aware datetime Series which required
realignment to perform the assignment, the timezone would be stripped
from the RHS on assignment.
…re_datetime_column

GH12981: addressed jreback's comment
@codecov-io
Copy link

codecov-io commented Apr 26, 2016

Current coverage is 83.85%

Merging #12982 into master will increase coverage by +<.01%

@@             master     #12982   diff @@
==========================================
  Files           136        136          
  Lines         49711      49711          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          41679      41683     +4   
+ Misses         8032       8028     -4   
  Partials          0          0          
  1. File ...as/core/internals.py (not in diff) was modified. more
    • Misses -4
    • Partials 0
    • Hits +4

Sunburst

Powered by Codecov. Last updated by 9445155

@jreback jreback closed this in cc67b72 Apr 26, 2016
@jreback
Copy link
Contributor

jreback commented Apr 26, 2016

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timezone lost on DataFrame assignments with realignment
4 participants