Skip to content

pandas.Series.multiply documentation examples correction  #23069

Closed
@rneubig

Description

@rneubig

Code Sample, a copy-pastable example if possible

Series.multiply(other, level=None, fill_value=None, axis=0)

Multiplication of series and other, element-wise (binary operator mul).

...

Examples:

a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
a
a 1.0
b 1.0
c 1.0
d NaN
dtype: float64
b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
b
a 1.0
b NaN
d 1.0
e NaN
dtype: float64
a.add(b, fill_value=0)
a 2.0
b 1.0
c 1.0
d 1.0
e NaN
dtype: float64

# Your code here

Examples:

>>> a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
>>> a
a    1.0
b    1.0
c    1.0
d    NaN
dtype: float64
>>> b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])
>>> b
a    1.0
b    NaN
d    1.0
e    NaN
dtype: float64
>>> a.multiply(b, fill_value=0)
a    1.0
b    0.0
c    0.0
d    0.0
e    NaN
dtype: float64

Problem description

[Example in pandas.Series.multiply Examples demonstrates the wrong function (add). Update to show multiply function as suggested above.]

Note: We receive a lot of issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates!

Note: Many problems can be resolved by simply upgrading pandas to the latest version. Before submitting, please check if that solution works for you. If possible, you may want to check if master addresses this issue, but that is not necessary.

For documentation-related issues, you can check the latest versions of the docs on master here:

https://pandas-docs.github.io/pandas-docs-travis/

If the issue has not been resolved there, go ahead and file it in the issue tracker.

Expected Output

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions