Skip to content

DOC: Fixed examples in pandas/core/arrays/ #33179

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

Merged

Conversation

ShaharNaveh
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Categories (3, object): [a < b < c]


Copy link
Member

Choose a reason for hiding this comment

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

do we need two lines here or just one?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think one.


Besides "See also" header, should come before the "Examples" header.

Ill fix that

@@ -181,7 +181,7 @@ def _unbox_scalar(self, value: Union[Period, Timestamp, Timedelta, NaTType]) ->

Examples
--------
>>> self._unbox_scalar(Timedelta('10s')) # DOCTEST: +SKIP
>>> _unbox_scalar(Timedelta('10s')) # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

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

i think this makes less sense without the self, but skipping is OK

Copy link
Member

Choose a reason for hiding this comment

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

I agree, let's keep the self here (this is an internal docstring and not a runnable example anyway)

Copy link
Member Author

Choose a reason for hiding this comment

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

I was trying to see if this will run without the "self", forgot to revert it.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks for working on those!

[b, a, c]
Categories (3, object): [b, a, c]
[b, a, a, b, c]
Categories (3, object): [a, b, c]
Copy link
Member

Choose a reason for hiding this comment

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

I think there are missing unique() calls here (and then the output should be correct), since we are in the unique docstring

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!

I got into a tunnel vision of just correcting the output, I guess I didn't even looked at what is the docstring I'm editing

>>> s.cat.add_categories(['d','e'])
Index(['a', 'b', 'c'], dtype='object')

>>> s.cat.categories = list("bcd")
Copy link
Member

Choose a reason for hiding this comment

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

I personally think we should remove this example ... (seems bad practice to me to modify the categorical like this in place)

3 NaN
dtype: category
Categories (2, object): [b, c]

>>> s.cat.remove_unused_categories()
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 assign the above one with add_categories to eg s2 and use that here? (so the remove_unused_categories actually has an effect)

@@ -181,7 +181,7 @@ def _unbox_scalar(self, value: Union[Period, Timestamp, Timedelta, NaTType]) ->

Examples
--------
>>> self._unbox_scalar(Timedelta('10s')) # DOCTEST: +SKIP
>>> _unbox_scalar(Timedelta('10s')) # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

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

I agree, let's keep the self here (this is an internal docstring and not a runnable example anyway)

3 3.0
4 NaN
5 NaN
dtype: float64
Copy link
Member

Choose a reason for hiding this comment

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

I would leave this out, since you already show the output of s below after setting the index, and it is the Series with the multi-index that is relevant for the rest of the example

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

checks are failing

@jbrockmendel
Copy link
Member

LGTM

@simonjayhawkins simonjayhawkins merged commit 25d893b into pandas-dev:master Apr 1, 2020
@simonjayhawkins simonjayhawkins added this to the 1.1 milestone Apr 1, 2020
@simonjayhawkins
Copy link
Member

Thanks @MomIsBestFriend

@ShaharNaveh ShaharNaveh deleted the DOC-DocTests-core-arrays branch April 1, 2020 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants