Skip to content

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

Merged

Conversation

charlesdong1991
Copy link
Member

@charlesdong1991 charlesdong1991 commented Nov 21, 2018

@charlesdong1991
Copy link
Member Author

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!

@@ -7,6 +7,9 @@

import numpy as np
import pandas as pd
from pandas.api.types import CategoricalDtype
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 these imports are better served where they were before. These aren't part of the top level API so no need to hide

Copy link
Member

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)

Copy link
Member Author

@charlesdong1991 charlesdong1991 Nov 21, 2018

Choose a reason for hiding this comment

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

oh, i see, thanks!!

@datapythonista
Copy link
Member

Not sure what is wrong with that test, but looks unrelated, I think I've seen it failing in other PRs too.

@datapythonista datapythonista changed the title DOC: Fix format of categorical.rst DOC: Fix flake8 issues in categorical.rst Nov 21, 2018
@WillAyd WillAyd added the Docs label Nov 21, 2018
Copy link
Member

@datapythonista datapythonista left a 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.

@@ -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))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
print("TypeError: " + str(e))
print("TypeError:", str(e))

except TypeError as e:
print("TypeError: " + str(e))
print("TypeError: " + str(e))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
print("TypeError: " + str(e))
print("TypeError:", str(e))

Copy link
Member Author

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.

try:
np.sum(s)
#same with np.log(s),..
# same with np.log(s),..
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# same with np.log(s),..
# same with np.log(s),...

Copy link
Member Author

Choose a reason for hiding this comment

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

changed

@codecov
Copy link

codecov bot commented Nov 21, 2018

Codecov Report

Merging #23839 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #23839   +/-   ##
=======================================
  Coverage   92.29%   92.29%           
=======================================
  Files         161      161           
  Lines       51490    51490           
=======================================
  Hits        47521    47521           
  Misses       3969     3969
Flag Coverage Δ
#multiple 90.68% <ø> (ø) ⬆️
#single 42.32% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 485e7cd...389fa49. Read the comment docs.

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

lgtm, thanks @charlesdong1991

df = pd.DataFrame({"cats": cats, "values": values}, index=idx)
df.iloc[2:4, :]
df.iloc[2:4, :].dtypes
df.loc["h": "j", "cats"]
Copy link
Member

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?

Copy link
Member Author

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...


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"])
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Ping on green

@datapythonista datapythonista merged commit 280781a into pandas-dev:master Nov 21, 2018
@datapythonista
Copy link
Member

Thanks a lot for these fixes @charlesdong1991

Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
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.

DOC: Fix format of categorical.rst
3 participants