-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update doc-string in Index.rename #22363
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #22363 +/- ##
==========================================
+ Coverage 92.05% 92.05% +<.01%
==========================================
Files 169 169
Lines 50713 50714 +1
==========================================
+ Hits 46683 46684 +1
Misses 4030 4030
Continue to review full report at Codecov.
|
pandas/core/indexes/base.py
Outdated
Int64Index([1, 2, 3, 4], dtype='int64', name='foo') | ||
>>> idx.rename('bar') | ||
Int64Index([1, 2, 3, 4], dtype='int64', name='bar') | ||
>>> idx = MultiIndex.from_tuples([(1, u'one'), (1, u'two'), |
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.
Should this have a newline to denote a separate example?
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.
Right. That looks better I think.
So I added newline in next commit
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.
Thanks for the PR!
Can you check your docstring with python scripts/validate_docstrings.py pandas.Index.rename
(and paste the output of it here in a comment) ?
pandas/core/indexes/base.py
Outdated
@@ -1340,17 +1345,40 @@ def set_names(self, names, level=None, inplace=False): | |||
def rename(self, name, inplace=False): | |||
""" | |||
Set new names on index. Defaults to returning new index. | |||
Length of names must match number of levels in MultiIndex. |
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.
Leave a blank line between the two lines above (the first line of the docstring should be a single line, see http://pandas.pydata.org/pandas-docs/stable/contributing_docstring.html#docstring for details)
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 changed some line with your suggestion.
and I put \
in the MultiIndex example to avoid error. and what happened in validation error..
thank you so much.
################################################################################
####################### Docstring (pandas.Index.rename) #######################
################################################################################
Set new names on index. Defaults to returning new index.
Length of names must match number of levels in MultiIndex.
Parameters
----------
name : str or sequence
name(s) to set
inplace : bool
if True, mutates in place
Returns
-------
new index (of same type and class...etc) [if inplace, returns None]
Examples
--------
>>> idx = pd.Index([1, 2, 3, 4], name='foo')
>>> idx.rename('bar')
Int64Index([1, 2, 3, 4], dtype='int64', name='bar')
>>> idx = pd.MultiIndex.from_tuples([(1, u'one'), (1, u'two'), (2, u'one'), (2, u'two')], names=['foo', 'bar'])
>>> idx.rename(['bar', None], inplace=True)
>>> idx
MultiIndex(levels=[[1, 2], ['one', 'two']],
labels=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=['bar', None])
>>> idx.rename(['bar'])
ValueError: Length of names must match number of levels in MultiIndex.
See also
--------
set_names : able to set new names partially and by level
################################################################################
################################## Validation ##################################
################################################################################
Errors found:
Errors in parameters section
Parameter "name" description should start with capital letter
Parameter "name" description should finish with "."
Parameter "inplace" description should start with capital letter
Parameter "inplace" description should finish with "."
Examples do not pass tests
################################################################################
################################### Doctests ###################################
################################################################################
**********************************************************************
Line 29, in pandas.Index.rename
Failed example:
idx.rename(['bar'])
Exception raised:
Traceback (most recent call last):
File "/home/mk/anaconda3/lib/python3.6/doctest.py", line 1330, in __run
compileflags, 1), test.globs)
File "<doctest pandas.Index.rename[5]>", line 1, in <module>
idx.rename(['bar'])
File "/home/mk/documents/dev/pandas-mk/pandas/core/indexes/base.py", line 1341, in set_names
idx._set_names(names, level=level)
File "/home/mk/documents/dev/pandas-mk/pandas/core/indexes/multi.py", line 672, in _set_names
raise ValueError('Length of names must match number of levels in '
ValueError: Length of names must match number of levels in MultiIndex.
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 fix the "Errors found:" ? (capitalization and punctuation)
pandas/core/indexes/base.py
Outdated
|
||
Examples | ||
-------- | ||
>>> idx = Index([1, 2, 3, 4], name='foo') |
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 use pd.
for pandas objects? (but no need to import it)
pandas/core/indexes/base.py
Outdated
>>> idx = MultiIndex.from_tuples([(1, u'one'), (1, u'two'), | ||
(2, u'one'), (2, u'two')], | ||
names=['foo', 'bar']) | ||
>>> idx.rename(['bar', None], inplace=True) |
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 would personally not show the inplace argument
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.
Wanted to show usage, but yours would be neat
pandas/core/indexes/base.py
Outdated
|
||
Parameters | ||
---------- | ||
name : str or list | ||
name to set | ||
name : str or sequence |
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.
is there a reason you changed 'list' to 'sequence' ?
I know it technically does accept any sequence, but in index names there can be a difference between a list (multiple names) and a tuple (single name), so I would rather keep it as list.
But it is true that a name is not limited to a string, so maybe we should use the more general "label" (and then "label, or list of labels")
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.
The reason why I used ‘sequence’ is that rename function takes not only list but also tuple in multiple names.
I am not sure it is intended, but it is.
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.
Yes, it is intended. But as I tried to explain, a tuple can also be a single name (so you can eg give a list of tuples). Therefore, I don't think the change is an improvement in clarity for the user.
I would strictly use 'list' for referring to the ability to give multiple names.
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.
but it works like this.
>>> idx = pd.MultiIndex(levels=[[1, 2], ['one', 'two']],\
... labels=[[0, 0, 1, 1], [0, 1, 0, 1]],\
... names=['bar', None])
>>> idx
MultiIndex(levels=[[1, 2], ['one', 'two']],
labels=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=['bar', None])
>>> idx.rename(('foo', 'bar'))
MultiIndex(levels=[[1, 2], ['one', 'two']],
labels=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=['foo', 'bar'])
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.
Yes, it know it works, but we should not encourage that.
For a single Index, there is a difference:
In [7]: idx = pd.Index([1, 2, 3, 4], name='foo')
In [8]: idx.rename(('bar', 'test'))
Out[8]: Int64Index([1, 2, 3, 4], dtype='int64', name=('bar', 'test'))
In [9]: idx.rename(['bar', 'test'])
...
TypeError: Int64Index.name must be a hashable type
So I would clearly state in our docstring one should use a list for multiple names (and not a sequence in general), to not confuse between those.
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.
oh, I got it. so list
means not only data type. thank you.
pandas/core/indexes/base.py
Outdated
@@ -1340,17 +1345,40 @@ def set_names(self, names, level=None, inplace=False): | |||
def rename(self, name, inplace=False): | |||
""" | |||
Set new names on index. Defaults to returning new index. | |||
Length of names must match number of levels in MultiIndex. |
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 fix the "Errors found:" ? (capitalization and punctuation)
pandas/core/indexes/base.py
Outdated
|
||
>>> idx = MultiIndex.from_tuples([(1, u'one'), (1, u'two'), | ||
(2, u'one'), (2, u'two')], | ||
names=['foo', 'bar']) |
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.
To get this passing for the doctests, you need to add ...
at the beginning of the line, as you see it in the console:
>>> idx = MultiIndex.from_tuples([(1, u'one'), (1, u'two'),
... (2, u'one'), (2, u'two')],
... names=['foo', 'bar'])
pandas/core/indexes/base.py
Outdated
labels=[[0, 0, 1, 1], [0, 1, 0, 1]], | ||
names=['bar', None]) | ||
>>> idx.rename(['bar']) | ||
ValueError: Length of names must match number of levels in MultiIndex. |
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.
To get this passing the doctests, see http://pandas.pydata.org/pandas-docs/stable/contributing_docstring.html#tips-for-getting-your-examples-pass-the-doctests
I fixed some details in ################################################################################
####################### Docstring (pandas.Index.rename) #######################
################################################################################
Set new names on index. Defaults to returning new index.
Length of names must match number of levels in MultiIndex.
Parameters
----------
name : str or list
Name(s) to set.
inplace : bool
If True, mutates in place.
Returns
-------
new index (of same type and class...etc) [if inplace, returns None]
Examples
--------
>>> idx = pd.Index([1, 2, 3, 4], name='foo')
>>> idx.rename('bar')
Int64Index([1, 2, 3, 4], dtype='int64', name='bar')
>>> idx = pd.MultiIndex.from_tuples([(1, u'one'), (1, u'two'),
... (2, u'one'), (2, u'two')],
... names=['foo', 'bar'])
>>> idx.rename(['bar', None])
MultiIndex(levels=[[1, 2], ['one', 'two']],
labels=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=['bar', None])
>>> idx.rename(['bar'])
Traceback (most recent call last):
ValueError: Length of names must match number of levels in MultiIndex.
See also
--------
set_names : able to set new names partially and by level
################################################################################
################################## Validation ##################################
################################################################################
Docstring for "pandas.Index.rename" correct. :) ################################################################################
###################### Docstring (pandas.Index.set_names) ######################
################################################################################
Set new names on index. Defaults to returning new index.
Parameters
----------
names : str or sequence
Name(s) to set.
level : int, level name, or sequence of int/level names (default None)
If the index is a MultiIndex (hierarchical), level(s) to set (None
for all levels). Otherwise level must be None.
inplace : bool
If True, mutates in place.
Returns
-------
new index (of same type and class...etc) [if inplace, returns None]
Examples
--------
>>> pd.Index([1, 2, 3, 4]).set_names('foo')
Int64Index([1, 2, 3, 4], dtype='int64', name='foo')
>>> pd.Index([1, 2, 3, 4]).set_names(['foo'])
Int64Index([1, 2, 3, 4], dtype='int64', name='foo')
>>> idx = pd.MultiIndex.from_tuples([(1, u'one'), (1, u'two'),
... (2, u'one'), (2, u'two')],
... names=['foo', 'bar'])
>>> idx.set_names(['baz', 'quz'])
MultiIndex(levels=[[1, 2], ['one', 'two']],
labels=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=['baz', 'quz'])
>>> idx.set_names('baz', level=0)
MultiIndex(levels=[[1, 2], ['one', 'two']],
labels=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=['baz', 'bar'])
See also
--------
rename : able to set new names without level
################################################################################
################################## Validation ##################################
################################################################################
Errors found:
No extended summary found |
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.
Thanks a lot for the updates!
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.
Thanks for the PR, added some minor comments.
pandas/core/indexes/base.py
Outdated
@@ -1283,12 +1283,12 @@ def set_names(self, names, level=None, inplace=False): | |||
Parameters | |||
---------- | |||
names : str or sequence | |||
name(s) to set | |||
Name(s) to set. | |||
level : int, level name, or sequence of int/level names (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.
We try to have the types more than description in this line. Something like the next would be more standard:
level: int, str, list of int or str, optional
In the description you can expand on explaining that it is the level index or name.
https://pandas.pydata.org/pandas-docs/stable/contributing_docstring.html#section-3-parameters
pandas/core/indexes/base.py
Outdated
inplace : bool | ||
if True, mutates in place | ||
If True, mutates in place. | ||
|
||
Returns | ||
------- |
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.
Do you mind changing the Return to a type too. Instead of "new index...", the type Index
in the first line, and the description in the next.
https://pandas.pydata.org/pandas-docs/stable/contributing_docstring.html#section-4-returns-or-yields
pandas/core/indexes/base.py
Outdated
|
||
See also | ||
-------- | ||
rename : able to set new names without level |
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.
See also should have a capital A
(See Also
) and should be placed before the examples. Also, the description should start with upper case and finish with a period.
Is rename
the method of Index
? For sphinx to create a link to it, it should be Index.rename
. Just rename would be understood as pandas.rename
which does not exist.
pandas/core/indexes/base.py
Outdated
|
||
See also | ||
-------- | ||
set_names : able to set new names partially and by level |
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.
Same as before.
pandas/core/indexes/base.py
Outdated
@@ -1300,17 +1300,22 @@ def set_names(self, names, level=None, inplace=False): | |||
Int64Index([1, 2, 3, 4], dtype='int64', name='foo') | |||
>>> pd.Index([1, 2, 3, 4]).set_names(['foo']) | |||
Int64Index([1, 2, 3, 4], dtype='int64', name='foo') |
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.
These 2 are duplicated, aren't they?
pandas/core/indexes/base.py
Outdated
(2, u'one'), (2, u'two')], | ||
names=['foo', 'bar']) | ||
... (2, u'one'), (2, u'two')], | ||
... names=['foo', 'bar']) |
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 think names
is overindented by one space.
pandas/core/indexes/base.py
Outdated
>>> idx = pd.MultiIndex.from_tuples([(1, u'one'), (1, u'two'), | ||
(2, u'one'), (2, u'two')], | ||
names=['foo', 'bar']) | ||
... (2, u'one'), (2, u'two')], |
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 think we can get rid of the unicode u
at the beginning of the strings.
I fixed detailed you said. and I changed one error msg to a proper one. now >>> idx = pd.MultiIndex.from_tuples([(1, 'one'), (1, 'two'),
... (2, 'one'), (2, 'two')],
... names=['foo', 'bar'])
>>> idx.rename(1, level=0)
MultiIndex(levels=[[1, 2], ['one', 'two']],
labels=[[0, 0, 1, 1], [0, 1, 0, 1]],
names=[1, 'bar']) should we prevent rename from getting level parameter? |
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.
Great work. Added some comments that IMO would make the docstring better.
pandas/core/indexes/base.py
Outdated
if True, mutates in place | ||
names : int, str, list-like, optional | ||
Name(s) to set. | ||
level : int, str, list-like, optional, 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.
No need for the default None
if we have optional
pandas/core/indexes/base.py
Outdated
names : int, str, list-like, optional | ||
Name(s) to set. | ||
level : int, str, list-like, optional, default None | ||
If the index is a MultiIndex(hierarchical), level(s) to set (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.
I don't find the hierarchical
necessary.
pandas/core/indexes/base.py
Outdated
|
||
Returns | ||
------- | ||
new index (of same type and class...etc) [if inplace, returns None] | ||
renamed : Index, MultiIndex or 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.
Just the type is enough, not need for the renamed
pandas/core/indexes/base.py
Outdated
|
||
See also | ||
-------- | ||
Index.rename : Able to set new names without level |
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 add a period at the end?
pandas/core/indexes/base.py
Outdated
renamed : Index, MultiIndex or None | ||
The same type as the caller or None if inplace is True. | ||
|
||
See also |
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.
Capital A
(See Also
)
pandas/core/indexes/base.py
Outdated
|
||
>>> idx = pd.MultiIndex.from_tuples([(1, 'one'), (1, 'two'), | ||
... (2, 'one'), (2, 'two')], | ||
... names=['foo', 'bar']) |
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 think in this case would help having a more real world example. At least for me is not so immediate to understand what we are dong, as replacing foo
by baz
is arbitrary. Having something like ['year', 'company']
changed to ['period', 'institution']
or something like this, IMO would make the example easier to understand.
pandas/core/indexes/base.py
Outdated
|
||
See also | ||
-------- | ||
Index.rename : Able to set new names without level | ||
|
||
Examples | ||
-------- | ||
>>> pd.Index([1, 2, 3, 4]).set_names('foo') | ||
Int64Index([1, 2, 3, 4], dtype='int64', name='foo') |
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'd assign the index to a variable idx
, display it, and then display it after setting the name. This example gives the impression that this is the right way to create an Index
with a name.
pandas/core/indexes/base.py
Outdated
@@ -1319,7 +1326,8 @@ def set_names(self, names, level=None, inplace=False): | |||
|
|||
if level is not None and not is_list_like(level) and is_list_like( | |||
names): | |||
raise TypeError("Names must be a string") | |||
msg = "Length of names must match number of levels in MultiIndex." |
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 think the previous error message was more appropriate. May be better to say something like Names must be a string when one level is provided
. But the new error message gives the impression that names should be a list, which is the not right.
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.
good. I will go for it
pandas/core/indexes/base.py
Outdated
|
||
See also | ||
-------- | ||
Index.set_names : Able to set new names partially and by level |
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.
Same as before for renamed
, See Also
and the period.
pandas/core/indexes/base.py
Outdated
names=['bar', None]) | ||
>>> idx.rename(['bar']) | ||
Traceback (most recent call last): | ||
ValueError: Length of names must match number of levels in MultiIndex. |
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.
Same as before regarding the examples.
pandas/core/indexes/base.py
Outdated
for all levels). Otherwise level must be None | ||
inplace : bool | ||
if True, mutates in place | ||
names : int, str, list-like, optional |
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 don't think we should try to list the possible types here (int, str
), as in principle an index name can be anything hashable, so not only ints or strings but also timestamps, tuples, ...
I seem to remember that we had such a discussion during the documentation sprint recently, and we ended up using the generic "label" (and then it can be "label, or list of labels")
BTW, this one is not optional I think?
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.
right, it was ended with the generic "label". but @datapythonista said that we should follow this.
https://pandas.pydata.org/pandas-docs/stable/contributing_docstring.html#section-3-parameters
So I was not sure that using "label" in there is right. which one do you think better?
and yes, it is not optional. it because of my bad misunderstanding. I will delete it.
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.
Yeah, sorry, we should update that text
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.
Yes, sorry, I meant object
instead of str
, this is what we've been using for what I know. We tried to keep them as Python types, but I'm happy using label
, it may be clearer. But if we use that, I'd prefer list of label
to list of labels
. This is consistent with list of str
or list of int
, and it will make it easier to parse and detect types automatically, if at some point that is useful.
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.
so can we go for names : int, str or list of labels
is okay? I cannot pick one..
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.
In this case I think names
expects label or list of label
if we go for the label
option. Or object or list of object
if we prefer the Python type. Am I right?
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 think label or list of label
looks better. or label or list of labels
Hello @Moons08! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on August 19, 2018 at 09:59 Hours UTC |
2ee70dc
to
1de9e73
Compare
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.
Looks great, thanks for all the changes. Just couple of small things.
pandas/core/indexes/base.py
Outdated
if True, mutates in place | ||
names : label or list of labels | ||
Name(s) to set. | ||
level : int, str or list of labels, optional |
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.
label
instead of str
pandas/core/indexes/base.py
Outdated
|
||
>>> idx = pd.MultiIndex.from_tuples([(1, 'one'), (1, 'two'), | ||
... (2, 'one'), (2, 'two')], | ||
... names=['year', 'company']) |
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'd display idx
after creating it. That will make it easier to compare with the result of .set_names()
.
If we have year
and company
, I'd have something like 2018
, Acme
in the values. I know I suggested it myself, but as I don't think we want to list company names, may be you can use something else?
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.
right, maybe we can use programming languages such as python, java, etc.
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'd avoid any data that can lead to controversy, even if it's small. I use animals most of the times. :)
pandas/core/indexes/base.py
Outdated
@@ -1319,7 +1329,8 @@ def set_names(self, names, level=None, inplace=False): | |||
|
|||
if level is not None and not is_list_like(level) and is_list_like( | |||
names): | |||
raise TypeError("Names must be a string") | |||
msg = "Names must be a string when one level is provided." |
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.
"when a single level" sounds clearer to me.
Thanks @Moons08, very good work, very clear docstring. |
updated doc-strings with examples
git diff upstream/master -u -- "*.py" | flake8 --diff