Skip to content

BUG: fix df concat containing mix of localized and non-localized Timestamps #12462

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
wants to merge 1 commit into from

Conversation

tsdlovell
Copy link
Contributor

BUG: fix issue with concat of localized timestamps
TST: test concat of dataframes with non-None timezone columns

@@ -46,6 +46,27 @@ def test_combine_multiple_frames_dtypes(self):
expected = Series(dict(float64=2, float32=2))
assert_series_equal(results, expected)

def test_combine_multiple_tzs(self):
ts1 = Timestamp('2015-01-01', tz=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

add the issue number here as well

@jreback jreback added Bug Timezones Timezone data dtype labels Feb 26, 2016
@tsdlovell
Copy link
Contributor Author

Created #12467 and added it in test comment

@jreback
Copy link
Contributor

jreback commented Feb 27, 2016

xref to #12396 which is closed by #12403

@jreback jreback modified the milestones: 0.18.0, 0.18.1 Feb 27, 2016
@jreback
Copy link
Contributor

jreback commented Apr 4, 2016

ping!

@tsdlovell
Copy link
Contributor Author

Hey Jeff, I've looked into the other failures a little but don't fully understand when/why the expected dims change. It looks like merge (the tests that fail) always wants a 1d array and is failing because we are using atleast_2d on one of our inputs to make our (2-d, 1-d) input combo compatible. Perhaps we should instead be making the 2-d into a 1-d? Is this just playing wack-a-mole?

@jreback
Copy link
Contributor

jreback commented Apr 4, 2016

a bit of a hack, but assure 2d-ness only when we are axis=1 concat.

diff --git a/pandas/tseries/common.py b/pandas/tseries/common.py
index f32e9b9..11a5fdc 100644
--- a/pandas/tseries/common.py
+++ b/pandas/tseries/common.py
@@ -260,8 +260,7 @@ def _concat_compat(to_concat, axis=0, typs=None):
         # if dtype is of datetimetz or timezone
         if x.dtype.kind == _NS_DTYPE.kind:
             if getattr(x, 'tz', None) is not None:
-                x = x.asobject
-                x = np.atleast_2d(x)
+                x = x.asobject.values
             else:
                 shape = x.shape
                 x = tslib.ints_to_pydatetime(x.view(np.int64).ravel())
@@ -272,6 +271,8 @@ def _concat_compat(to_concat, axis=0, typs=None):
             x = tslib.ints_to_pytimedelta(x.view(np.int64).ravel())
             x = x.reshape(shape)

+        if axis == 1:
+            x = np.atleast_2d(x)
         return x

     if typs is None:

@tsdlovell
Copy link
Contributor Author

That passes the tests that were failing. Unfortunately, can't push from work. Will make that change this evening.

@jreback
Copy link
Contributor

jreback commented Apr 4, 2016

@tsdlovell np.

@tsdlovell
Copy link
Contributor Author

travis is failing on OSX and py3.5 at the same points

ERROR: test_range_slice_day (pandas.tseries.tests.test_period.TestPeriodIndex)

Traceback (most recent call last):
File "/Users/travis/build/pydata/pandas/pandas/tseries/tests/test_period.py", line 2619, in test_range_slice_day
idx[v:]
File "/Users/travis/build/pydata/pandas/pandas/tseries/base.py", line 176, in getitem
result = getitem(key)

IndexError: failed to coerce slice entry of type str to integer

ERROR: test_range_slice_seconds (pandas.tseries.tests.test_period.TestPeriodIndex)

Traceback (most recent call last):
File "/Users/travis/build/pydata/pandas/pandas/tseries/tests/test_period.py", line 2676, in test_range_slice_seconds
idx[v:]
File "/Users/travis/build/pydata/pandas/pandas/tseries/base.py", line 176, in getitem
result = getitem(key)
IndexError: failed to coerce slice entry of type str to integer

Was working in the env I created a bit ago, but fails in an env I just created, so maybe something to do with change in dependencies. Will look into it.

@jreback
Copy link
Contributor

jreback commented Apr 5, 2016

numpy 1.11 was just updated fully in conda
I am about to push the fixes for this

@jreback
Copy link
Contributor

jreback commented Apr 5, 2016

rebase and should be good to go

TST: test concat of dataframes with non-None timezone columns
@jreback
Copy link
Contributor

jreback commented Apr 6, 2016

@tsdlovell thank you sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants