Skip to content

DOC: update the pandas.IntervalIndex docstring #20188

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

verakai
Copy link
Contributor

@verakai verakai commented Mar 10, 2018

Docstring assignated to the Buenos Aires, Argentina chapter.

Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):

  • PR title is "DOC: update the docstring"
  • The validation script passes: scripts/validate_docstrings.py <your-function-or-method>
  • The PEP8 style check passes: git diff upstream/master -u -- "*.py" | flake8 --diff
  • The html version looks good: python doc/make.py --single <your-function-or-method>
  • It has been proofread on language by another sprint participant

Please include the output of the validation script below between the "```" ticks:


################################################################################
####################### Docstring (pandas.IntervalIndex) #######################
################################################################################

Immutable Index implementing an ordered, sliceable set. IntervalIndex
represents an Index of Interval objects that are all closed on the same
side.

.. versionadded:: 0.20.0

.. warning::

   The indexing behaviors are provisional and may change in
   a future version of pandas.

Parameters
----------
data : array-Like (1-dimensional)
    Array-like containing Interval objects from which to build the
    IntervalIndex.
closed : {'left', 'right', 'both', 'neither'}, default 'right'
    Whether the intervals are closed on the left-side, right-side, both or
    neither.
dtype : dtype or None, default None
    If None, dtype will be inferred.
copy : boolean, default False
    Copy the meta-data.
name : object, optional
    Name to be stored in the index.
fastpath : boolean, default False
    Create IntervalIndex without verifying integrity.
verify_integrity : boolean, default True
    Verify that the IntervalIndex is valid.
    
    ..versionadded:: 0.23.0.

Attributes
----------
left
right
closed
mid
length
values
is_non_overlapping_monotonic

Methods
-------
from_arrays
from_tuples
from_breaks
contains

Examples
---------
A new ``IntervalIndex`` is typically constructed using
:func:`interval_range`:

>>> pd.interval_range(start=0, end=5)
IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]]
              closed='right', dtype='interval[int64]')

It may also be constructed using one of the constructor
methods: :meth:`IntervalIndex.from_arrays`,
:meth:`IntervalIndex.from_breaks`, and :meth:`IntervalIndex.from_tuples`.

See further examples in the doc strings of ``interval_range`` and the
mentioned constructor methods.

Notes
------
See the `user guide
<http://pandas.pydata.org/pandas-docs/stable/advanced.html#intervalindex>`_
for more.

See Also
--------
Index : The base pandas Index type.
Interval : A bounded slice-like interval; the elements of an IntervalIndex.
qcut : Quantile-based discretization function.
cut : Return indices of half-open bins to which each value of x belongs.
interval_range : Function to create a fixed frequency IntervalIndex.

################################################################################
################################## Validation ##################################
################################################################################

Errors found:
	No returns section found
Checking `class` definition so nothing to return 

If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.

@pep8speaks
Copy link

Hello @verakai! Thanks for submitting the PR.

Line 161:1: W293 blank line contains whitespace

@@ -142,20 +142,24 @@ class IntervalIndex(IntervalMixin, Index):

Parameters
----------
data : array-like (1-dimensional)
data : array-Like (1-dimensional)
Copy link
Contributor

Choose a reason for hiding this comment

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

array-like is correct

closed : {'left', 'right', 'both', 'neither'}, default 'right'
Whether the intervals are closed on the left-side, right-side, both or
neither.
dtype : dtype or None, default None
Copy link
Contributor

Choose a reason for hiding this comment

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

numpy dtype, optional

closed : {'left', 'right', 'both', 'neither'}, default 'right'
Whether the intervals are closed on the left-side, right-side, both or
neither.
dtype : dtype or None, default None
If None, dtype will be inferred.
copy : boolean, default False
Copy link
Contributor

Choose a reason for hiding this comment

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

boolean -> bool

dtype : dtype or None, default None
If None, dtype will be inferred.
copy : boolean, default False
Copy the meta-data.
Copy link
Contributor

Choose a reason for hiding this comment

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

this refers to copying of the input data

@jreback jreback added Docs Interval Interval data type labels Mar 10, 2018
@jreback
Copy link
Contributor

jreback commented Mar 10, 2018

cc @jschendel if you'd have a look

@jschendel
Copy link
Member

jschendel commented Mar 11, 2018

Looks like these changes were also included in #20224, and there are a few related comments there.

Array-like containing Interval objects from which to build the
IntervalIndex
IntervalIndex.
closed : {'left', 'right', 'both', 'neither'}, default 'right'
Copy link
Member

Choose a reason for hiding this comment

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

Can you swap the order of 'left' and 'right' here (and on the line below), so the default value appears first. I think some of the other Interval related PRs from the sprint did the same thing, and it'd be nice to make this consistent.

@jschendel
Copy link
Member

Closing in favor of #23157

@jschendel jschendel closed this Oct 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Interval Interval data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants