Skip to content

BUG: examples for pd.interval_range do not work #17707

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
topper-123 opened this issue Sep 28, 2017 · 2 comments
Closed

BUG: examples for pd.interval_range do not work #17707

topper-123 opened this issue Sep 28, 2017 · 2 comments
Labels
Bug Interval Interval data type
Milestone

Comments

@topper-123
Copy link
Contributor

topper-123 commented Sep 28, 2017

Code Sample, a copy-pastable example if possible

In the doc string for interval_range there are 2 of the four example that deal with time. They both fail when run:

    >>> pd.interval_range(start=pd.Timestamp('2017-01-01'),
                          end=pd.Timestamp('2017-01-04'))
    ValueError: start, end, freq need to be the same type

    >>> pd.interval_range(start=pd.Timestamp('2017-01-01'),
                          periods=3, freq='MS')
    TypeError: unsupported operand type(s) for +: 'Timestamp' and 'str'

Both of these give errors when run.

Problem description

The examples given seem reasonable for a IntervalIndex (unless time intervals should be PeriodIndex). My guess is that some too-strict check has crept in somewhere along the coding process.

Expected Output

In both cases IntervalIndex objects.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.2.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.20.3
pytest: 3.2.2
pip: 9.0.1
setuptools: 36.5.0
Cython: 0.25.2
numpy: 1.13.1
scipy: 0.19.1
xarray: None
IPython: 6.1.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.5
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: 3.7.3
bs4: 4.5.3
html5lib: 0.999999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Sep 28, 2017

They seem already to work on master:

In [125]: pd.interval_range(start=pd.Timestamp('2017-01-01'),
     ...:                           end=pd.Timestamp('2017-01-04'))              
Out[125]: 
IntervalIndex([(2017-01-01, 2017-01-02], (2017-01-02, 2017-01-03], (2017-01-03, 2017-01-04]]
              closed='right',
              dtype='interval[datetime64[ns]]')

In [126]: pd.interval_range(start=pd.Timestamp('2017-01-01'),
     ...:                           periods=3, freq='MS')                      
Out[126]: 
IntervalIndex([(2017-01-01, 2017-02-01], (2017-02-01, 2017-03-01], (2017-03-01, 2017-04-01]]
              closed='right',
              dtype='interval[datetime64[ns]]')

In [129]: pd.__version__
Out[129]: '0.21.0.dev+510.g62e19b2'

Tests for this have been added recently in #17482 (not sure if they were fixed there as well, or already previously. But I can confirm that they fail in 0.20.3)

@jorisvandenbossche jorisvandenbossche added this to the 0.21.0 milestone Sep 28, 2017
@jorisvandenbossche jorisvandenbossche added Bug Interval Interval data type labels Sep 28, 2017
@topper-123
Copy link
Contributor Author

Ok, thanks for checking.

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

No branches or pull requests

2 participants