Skip to content

date_range breaks with tz-aware start/end dates and closed intervals in 0.18.0.rc1 #12409

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
multiloc opened this issue Feb 21, 2016 · 2 comments
Labels
Regression Functionality that used to work in a prior pandas version Timezones Timezone data dtype
Milestone

Comments

@multiloc
Copy link
Contributor

The following works on 0.17.1 but breaks on the release candidate 0.18.0.rc1

>>> import pandas as pd
>>> pd.date_range(start=pd.Timestamp('20150101', tz='UTC'), end=pd.Timestamp('20150105', tz='UTC'), closed='left')
DatetimeIndex(['2015-01-01', '2015-01-02', '2015-01-03', '2015-01-04'], dtype='datetime64[ns, UTC]', freq='D')

On 0.18.0.rc1:

In [2]: pd.date_range(start=pd.Timestamp('20150101', tz='UTC'), end=pd.Timestamp('20150105', tz='UTC'), closed='left')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-b04844565a59> in <module>()
----> 1 pd.date_range(start=pd.Timestamp('20150101', tz='UTC'), end=pd.Timestamp('20150105', tz='UTC'), closed='left')

/.../pandas/tseries/index.py in date_range(start, end, periods, freq, tz, normalize, name, closed, **kwargs)
   2033     return DatetimeIndex(start=start, end=end, periods=periods,
   2034                          freq=freq, tz=tz, normalize=normalize, name=name,
-> 2035                          closed=closed, **kwargs)
   2036 
   2037 

/.../pandas/util/decorators.py in wrapper(*args, **kwargs)
     89                 else:
     90                     kwargs[new_arg_name] = new_arg_value
---> 91             return func(*args, **kwargs)
     92         return wrapper
     93     return _deprecate_kwarg

/.../pandas/tseries/index.py in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, closed, ambiguous, dtype, **kwargs)
    259             return cls._generate(start, end, periods, name, freq,
    260                                  tz=tz, normalize=normalize, closed=closed,
--> 261                                  ambiguous=ambiguous)
    262 
    263         if not isinstance(data, (np.ndarray, Index, ABCSeries)):

/.../pandas/tseries/index.py in _generate(cls, start, end, periods, name, offset, tz, normalize, ambiguous, closed)
    532         if not left_closed and len(index) and index[0] == start:
    533             index = index[1:]
--> 534         if not right_closed and len(index) and index[-1] == end:
    535             index = index[:-1]
    536 

/.../pandas/tslib.pyx in pandas.tslib._Timestamp.__richcmp__ (pandas/tslib.c:18791)()
    975                                 (type(self).__name__, type(other).__name__))
    976 
--> 977         self._assert_tzawareness_compat(other)
    978         return _cmp_scalar(self.value, ots.value, op)
    979 

/.../pandas/tslib.pyx in pandas.tslib._Timestamp._assert_tzawareness_compat (pandas/tslib.c:19145)()
   1007                                  'timestamps')
   1008         elif other.tzinfo is None:
-> 1009             raise TypeError('Cannot compare tz-naive and tz-aware timestamps')
   1010 
   1011     cpdef datetime to_datetime(_Timestamp self):

TypeError: Cannot compare tz-naive and tz-aware timestamps
@multiloc
Copy link
Contributor Author

The fix looks simple, I'll post a PR in a bit

@jreback
Copy link
Contributor

jreback commented Feb 21, 2016

gr8!

@jreback jreback added Regression Functionality that used to work in a prior pandas version Timezones Timezone data dtype labels Feb 21, 2016
@jreback jreback added this to the 0.18.0 milestone Feb 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression Functionality that used to work in a prior pandas version Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants