Skip to content

DOC: improve binary operator docs (fixes #10093) #10107

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
merged 1 commit into from
May 16, 2015

Conversation

mortada
Copy link
Contributor

@mortada mortada commented May 11, 2015

fixes #10093

@jorisvandenbossche this covers Series, DataFrame and Panel, please take a look

@jorisvandenbossche
Copy link
Member

The resulting text would now be: Binary operator subtraction.

I think that maybe also the 'binary operator' part can be confusing for people. I don't know if this terminology is that familiar for most users?
Thinking about an alternative, I came up with Subtraction of series and other (binary operator ``sub``).

@jorisvandenbossche jorisvandenbossche added this to the 0.17.0 milestone May 12, 2015
@mortada
Copy link
Contributor Author

mortada commented May 12, 2015

actually the current implementation is such that the doc would be: Binary operator sub (subtraction)

@jorisvandenbossche
Copy link
Member

Ah, yes, I see the desc line!
But still, my reservation about 'binary operator' stays the same (but to be clear, just adding the full name between parantheses is already a big improvement)

@mortada
Copy link
Contributor Author

mortada commented May 12, 2015

hmm... yeah the wording for this is kind of tricky

@mortada
Copy link
Contributor Author

mortada commented May 13, 2015

if we go with Subtraction of series and other (binary operator sub) maybe it should be Subtraction of other from series instead to indicate the order of operation, and so rsub would be Subtraction of series from other. But I'm not sure if this is actually more clear.

@jorisvandenbossche
Copy link
Member

Proposal:

Subtraction of series and other, element-wise (binary operator `sub`).

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

But agree that the "series and other" is maybe better as "other from series", but that will depend a bit from operator to operator how to best specify it.

Can you maybe also add a 'see also' section each time to the reversed/non-reversed version (add -> radd, radd -> add, ...)

@mortada
Copy link
Contributor Author

mortada commented May 14, 2015

So I ended up restructuring the code quite a bit in order to pack more information into the docstring, also added a unit test for it. Please take a look.

Basically the docstrings look like this now:

Signature: pd.DataFrame.sub(self, other, axis='columns', level=None, fill_value=None)
Docstring:
Subtraction of dataframe and other, element-wise (binary operator `-`).

Equivalent to ``dataframe - other``, 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
fill_value : None or float value, default None
    Fill missing (NaN) values with this value. If both DataFrame locations are
    missing, the result will be missing
level : int or name
    Broadcast across a level, matching Index values on the
    passed MultiIndex level

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

Returns
-------
result : DataFrame

See also
--------
DataFrame.rsub

@jorisvandenbossche
Copy link
Member

Nice! Thanks a lot.

@mortada
Copy link
Contributor Author

mortada commented May 15, 2015

Noticed a small problem, instead of:
element-wise (binary operator -)
we should have:
element-wise (binary operator sub)

it's fixed now

@jorisvandenbossche
Copy link
Member

Travis is failing, but seems to be related to another issue

@jreback
Copy link
Contributor

jreback commented May 16, 2015

yep will be fixed by #10152

@jorisvandenbossche
Copy link
Member

OK, merging then. @mortada Thanks a lot!

jorisvandenbossche added a commit that referenced this pull request May 16, 2015
DOC: improve binary operator docs (fixes #10093)
@jorisvandenbossche jorisvandenbossche merged commit 11b1133 into pandas-dev:master May 16, 2015
@mortada mortada deleted the binary_op_docs branch May 18, 2015 19:06
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.17.0, 0.16.2 Jun 2, 2015
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: clarify docstring of DataFrame.sub et al
3 participants