-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: update the DataFrame.applymap docstring #20136
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
Apply a function to a DataFrame that is intended to operate | ||
elementwise, i.e. like doing map(func, series) for each series in the | ||
DataFrame | ||
Apply a function to a Dataframe elementwise. |
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.
Maybe a "elementwise function" or a "scalar function", I'm not sure.
pandas/core/frame.py
Outdated
Apply a function to a Dataframe elementwise. | ||
|
||
This method applies a function to a DataFrame that is intended to | ||
operate elementwise, i.e. like doing map(func, series) for each series |
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.
We should probably mark it as code `map(func, series)
`
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! addressed
pandas/core/frame.py
Outdated
|
||
Returns | ||
------- | ||
applied : DataFrame | ||
pandas.DataFrame | ||
A transformed DataFrame. |
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.
Possibly, remove the "A" .
pandas/core/frame.py
Outdated
|
||
>>> df = pd.DataFrame(np.random.RandomState(0).randn(3, 3)) |
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.
In the Conventions for the examples mentions:
avoid using data without interpretation, like a matrix of random numbers with columns A, B, C, D… And instead use a meaningful example, which makes it easier to understand the concept
In fact, this one looks like the Bad example :-P
I'd suggest improving this example.
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 for the comment, actually we updated previous random example to a deterministic one by hardcoding the random seed through RandomState(0). Since we are illustrating an elementwise mapping it might be easier to use a matrix [[1,2],[3,4]] and square it.
[ci skip]
Codecov Report
@@ Coverage Diff @@
## master #20136 +/- ##
==========================================
- Coverage 91.72% 91.7% -0.03%
==========================================
Files 150 150
Lines 49156 49152 -4
==========================================
- Hits 45090 45074 -16
- Misses 4066 4078 +12
Continue to review full report at Codecov.
|
[ci skip]
Thanks @orereta ! |
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks: