Skip to content

DOC: fix the pandas.DataFrame.add example #20077

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

robinkiplangat
Copy link

@robinkiplangat robinkiplangat commented Mar 9, 2018

Docstring assigned to the PyData Nairobi chapter for the sprint
Checklist for the pandas documentation sprint

  • PR title is "DOC: update the pandas.DataFrame.rmul docstring"
  • The validation script passes: scripts/validate_docstrings.py pandas.DataFrame.rmul
  • The PEP8 style check passes: git diff upstream/master -u -- "*.py" | flake8 --diff
  • The html version looks good: python doc/make.py --single pandas.DataFrame.rmul
  • It has been proofread on language by another sprint participant

Please include the output of the validation script below between the "```" ticks:

scripts/validate_docstrings.py pandas.DataFrame.rmul

################################################################################
###################### Docstring (pandas.DataFrame.rmul)  ######################
################################################################################

Multiplication of dataframe and other, element-wise (binary operator `rmul`).

Equivalent to ``other * dataframe``, but with support to substitute a fill_value for
missing data in one of the inputs.

Parameters
----------
other : Series, DataFrame, or constant
axis : {0, 1, 'index', 'columns'}
    For Series input, axis to match Series index on
level : int or name
    Broadcast across a level, matching Index values on the
    passed MultiIndex level
fill_value : None or float value, default None
    Fill existing missing (NaN) values, and any new element needed for
    successful DataFrame alignment, with this value before computation.
    If data in both corresponding DataFrame locations is missing
    the result will be missing

Notes
-----
Mismatched indices will be unioned together

Returns
-------
result : DataFrame

Examples
--------
>>> a = pd.DataFrame([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'],
...                  columns=['one'])
>>> a
   one
a  1.0
b  1.0
c  1.0
d  NaN
>>> b = pd.DataFrame(dict(one=[1, np.nan, 1, np.nan],
...                       two=[np.nan, 2, np.nan, 2]),
...                   index=['a', 'b', 'd', 'e'])
>>> b
   one  two
a  1.0  NaN
b  NaN  2.0
d  1.0  NaN
e  NaN  2.0
>>> a.add(b, fill_value=0)
   one  two
a  2.0  NaN
b  1.0  2.0
c  1.0  NaN
d  1.0  NaN
e  NaN  2.0

See also
--------
DataFrame.mul

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.DataFrame.rmul" correct. :)

If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.

two=[np.nan, 2, np.nan, 2]),
index=['a', 'b', 'd', 'e'])
... two=[np.nan, 2, np.nan, 2]),
... index=['a', 'b', 'd', 'e'])
Copy link
Contributor

Choose a reason for hiding this comment

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

May need one more space here, so that the "i" in "index" is below the "d" in "dict'.

@@ -513,14 +513,14 @@ def _get_op_name(op, special):
other : Series, DataFrame, or constant
axis : {{0, 1, 'index', 'columns'}}
For Series input, axis to match Series index on
level : int or name
Copy link
Contributor

Choose a reason for hiding this comment

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

I think level : int or str, though we're inconsistent here.

@jorisvandenbossche what should our policy be on index positions or labels? In principle, int or str isn't quite right since index labels needn't be strings. It'd be int or object, which isn't that informative. int or label?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, yes, this is a dubious one. "name" is technically not a 'type', but "str" would not be correct as you say. So maybe better to keep it that way.

If we keep the 'name' or 'label', wouldn't 'name' be better because it is here a index level name, not a label inside the index ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes you're right I was mistaken.

And we can declare that "name" means anything that can go in {.index,.columns}{.name,.names}.

@codecov
Copy link

codecov bot commented Mar 9, 2018

Codecov Report

Merging #20077 into master will decrease coverage by 0.07%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20077      +/-   ##
==========================================
- Coverage   91.77%    91.7%   -0.08%     
==========================================
  Files         152      150       -2     
  Lines       49175    49122      -53     
==========================================
- Hits        45130    45045      -85     
- Misses       4045     4077      +32
Flag Coverage Δ
#multiple 90.08% <ø> (-0.08%) ⬇️
#single 41.86% <ø> (+0.01%) ⬆️
Impacted Files Coverage Δ
pandas/core/ops.py 96.33% <ø> (-0.02%) ⬇️
pandas/plotting/_compat.py 62% <0%> (-28.91%) ⬇️
pandas/io/html.py 85.98% <0%> (-2.81%) ⬇️
pandas/core/arrays/base.py 74.35% <0%> (-2.39%) ⬇️
pandas/io/formats/format.py 96.26% <0%> (-1.99%) ⬇️
pandas/plotting/_converter.py 65.07% <0%> (-1.74%) ⬇️
pandas/core/reshape/melt.py 97.19% <0%> (-0.15%) ⬇️
pandas/compat/__init__.py 57.62% <0%> (-0.12%) ⬇️
pandas/plotting/_core.py 82.23% <0%> (-0.04%) ⬇️
pandas/core/indexes/period.py 92.57% <0%> (-0.04%) ⬇️
... and 26 more

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 8c7d1f6...ca3e5f9. Read the comment docs.

@jreback jreback added the Docs label Mar 10, 2018
@jorisvandenbossche jorisvandenbossche changed the title DOC: update the pandas.DataFrame.rmul docstring DOC: fix the pandas.DataFrame.add example Mar 15, 2018
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.

Fixed the merge conflict.

@jorisvandenbossche jorisvandenbossche merged commit 87f5654 into pandas-dev:master Mar 15, 2018
@jorisvandenbossche
Copy link
Member

@4bic Thanks!

@jorisvandenbossche jorisvandenbossche added this to the 0.23.0 milestone Mar 15, 2018
@robinkiplangat
Copy link
Author

Hi @jorisvandenbossche,
DOC:update the pandas.DataFrame.rmul docstring was renamed as a DOC:fix the pandas.DataFrame.add example.

Was the dostring the same for the pandas.DataFrame.rmul and pandas.DataFrame.add example

@jorisvandenbossche
Copy link
Member

Ah, I renamed because the example you fixed was for add, but the other changes were for both rmul and add

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