-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Fix flake8 issues in categorical.rst #23839
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: Fix flake8 issues in categorical.rst #23839
Conversation
Hi, @datapythonista , if you are free, could you take a look at the error message? i don't understand what caused this test to fail. thank you very much! |
doc/source/categorical.rst
Outdated
@@ -7,6 +7,9 @@ | |||
|
|||
import numpy as np | |||
import pandas as pd | |||
from pandas.api.types import CategoricalDtype |
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 these imports are better served where they were before. These aren't part of the top level API so no need to hide
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.
Agree, I think flake8-rst
is reporting as errors having these imports in the blocks, but that should be ignored in the config: #23802 (comment)
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 see, thanks!!
Not sure what is wrong with that test, but looks unrelated, I think I've seen it failing in other PRs too. |
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, added couple of small details as suggestions, and if you can restore the position of the imports, I think we're ready to merge.
doc/source/categorical.rst
Outdated
@@ -1105,7 +1117,7 @@ NumPy itself doesn't know about the new `dtype`: | |||
try: | |||
np.dtype(dtype) | |||
except TypeError as e: | |||
print("TypeError: " + str(e)) | |||
print("TypeError: " + str(e)) |
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.
print("TypeError: " + str(e)) | |
print("TypeError:", str(e)) |
doc/source/categorical.rst
Outdated
except TypeError as e: | ||
print("TypeError: " + str(e)) | ||
print("TypeError: " + str(e)) |
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.
print("TypeError: " + str(e)) | |
print("TypeError:", str(e)) |
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, changed this and applied the same to others.
doc/source/categorical.rst
Outdated
try: | ||
np.sum(s) | ||
#same with np.log(s),.. | ||
# same with np.log(s),.. |
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 with np.log(s),.. | |
# same with np.log(s),... |
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.
changed
Codecov Report
@@ Coverage Diff @@
## master #23839 +/- ##
=======================================
Coverage 92.29% 92.29%
=======================================
Files 161 161
Lines 51490 51490
=======================================
Hits 47521 47521
Misses 3969 3969
Continue to review full report at Codecov.
|
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.
lgtm, thanks @charlesdong1991
doc/source/categorical.rst
Outdated
df = pd.DataFrame({"cats": cats, "values": values}, index=idx) | ||
df.iloc[2:4, :] | ||
df.iloc[2:4, :].dtypes | ||
df.loc["h": "j", "cats"] |
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.
Hmm this doesn’t seem right - no need for spacing after colon, no?
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.
ahh, yeah, right!! thanks for the check!! sorry for my carelessness...
doc/source/categorical.rst
Outdated
|
||
Setting values by assigning categorical data will also check that the `categories` match: | ||
|
||
.. ipython:: python | ||
|
||
df.loc["j":"k","cats"] = pd.Categorical(["a","a"], categories=["a","b"]) | ||
df.loc["j": "k", "cats"] = pd.Categorical(["a", "a"], categories=["a", "b"]) |
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 comment here
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.
Ping on green
Thanks a lot for these fixes @charlesdong1991 |
git diff upstream/master -u -- "*.py" | flake8 --diff