-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the IntervalIndex.from_array docstring #20224
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
DOC: update the IntervalIndex.from_array docstring #20224
Conversation
…_docstring updating befor commit
….from_array_docstring
….from_array_docstring
pandas/core/indexes/interval.py
Outdated
@@ -142,20 +142,24 @@ class IntervalIndex(IntervalMixin, Index): | |||
|
|||
Parameters | |||
---------- | |||
data : array-like (1-dimensional) | |||
data : array-Like (1-dimensional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array-like is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also could you limit your changes to just the from_array method? Don't want conflicts with others.
pandas/core/indexes/interval.py
Outdated
[13, 19) teen | ||
dtype: object | ||
|
||
Notes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thin kthe order is Returns, Notes, See Also, then Examples.
pandas/core/indexes/interval.py
Outdated
@@ -457,7 +461,8 @@ def from_breaks(cls, breaks, closed='right', name=None, copy=False, | |||
def from_arrays(cls, left, right, closed='right', name=None, copy=False, | |||
dtype=None): | |||
""" | |||
Construct an IntervalIndex from a a left and right array | |||
Construct an IntervalIndex from a given element in a left | |||
and right array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try to keep this in a single line? I also don't fully understand the "from a given element in ", so would maybe remove that part
pandas/core/indexes/interval.py
Outdated
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is the explanation in the cut docstring, but it is actually not correct (we are having a discussion about this in the PR doing the cut function :)). I would keep the explanation that was there before about converting array of continuous data into intervals
pandas/core/indexes/interval.py
Outdated
@@ -471,11 +476,15 @@ def from_arrays(cls, left, right, closed='right', name=None, copy=False, | |||
name : object, optional | |||
Name to be stored in the index. | |||
copy : boolean, default False | |||
copy the data | |||
Copy the data. | |||
dtype : dtype or None, default None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change "dtype or None, default None" to "dtype, optional" ?
pandas/core/indexes/interval.py
Outdated
Notes | ||
----- | ||
Each element of `left` must be smaller or equal to the `right` element | ||
at the same position, ie, ``left[i] <= right[i]``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add that all elements within each array should have similar type? For example, the following raises on master since the mixed types result in object
subtype (works on 0.22.0, but will be disallowed in the next release):
In [2]: pd.__version__
Out[2]: '0.23.0.dev0+482.gc3d491a'
In [3]: left = [1, pd.Timestamp('20180101')]
In [4]: right = [2, pd.Timestamp('20180201')]
In [5]: pd.IntervalIndex.from_arrays(left, right)
---------------------------------------------------------------------------
TypeError: category, object, and string subtypes are not supported for IntervalIndex
pandas/core/indexes/interval.py
Outdated
|
||
Notes | ||
----- | ||
Each element of `left` must be smaller or equal to the `right` element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
smaller --> less than
Codecov Report
@@ Coverage Diff @@
## master #20224 +/- ##
=========================================
Coverage ? 91.72%
=========================================
Files ? 150
Lines ? 49152
Branches ? 0
=========================================
Hits ? 45086
Misses ? 4066
Partials ? 0
Continue to review full report at Codecov.
|
[ci skip]
Thanks @verakai! |
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>