Skip to content
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

DOC: Fix Dataframe.apply documentation to include note regarding calling function twice on first element #33879

Closed
alonme opened this issue Apr 29, 2020 · 0 comments · Fixed by #34183
Labels
Milestone

Comments

@alonme
Copy link
Contributor

alonme commented Apr 29, 2020

Location of the documentation

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.apply.html

Documentation problem

In commit f625730 the documentation of df.apply was changed, and a note regarding df.apply behavior to call the applied function twice on the first column/row.

As far as i can tell from this issue and from my own testing (See below) this behavior still exists.

In [1]:  import pandas as pd

In [2]: df = pd.DataFrame({'a': [1,2,3]})

In [3]: def mul2(x):
    ...:     print('Hello')
    ...:     return x*2
    ...:

In [4]: df.apply(mul2)
Hello
Hello
Out[4]:
   a
0  2
1  4
2  6

In [5]: pd.show_versions()

INSTALLED VERSIONS
------------------
commit           : None
python           : 3.7.5.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 19.3.0
machine          : x86_64
processor        : i386
byteorder        : little
LC_ALL           : en_US.UTF-8
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8

pandas           : 1.0.3
numpy            : 1.18.2
pytz             : 2019.3
dateutil         : 2.8.1
pip              : 19.3.1
setuptools       : 41.2.0
Cython           : None
pytest           : 5.3.2
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : None
html5lib         : 1.0.1
pymysql          : None
psycopg2         : 2.8.4 (dt dec pq3 ext lo64)
jinja2           : 2.11.1
IPython          : 7.13.0
pandas_datareader: None
bs4              : None
bottleneck       : None
fastparquet      : 0.3.3
gcsfs            : None
lxml.etree       : None
matplotlib       : 3.2.1
numexpr          : None
odfpy            : None
openpyxl         : None
pandas_gbq       : 0.13.1
pyarrow          : None
pytables         : None
pytest           : 5.3.2
pyxlsb           : None
s3fs             : None
scipy            : 1.4.1
sqlalchemy       : 1.3.12
tables           : None
tabulate         : None
xarray           : 0.15.1
xlrd             : None
xlwt             : None
xlsxwriter       : None
numba            : 0.47.0

Suggested fix for documentation

Revert commit f625730 in order to reflect the actual behavior of the apply function

@alonme alonme added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 29, 2020
@jreback jreback added this to the 1.1 milestone Jun 2, 2020
@bashtage bashtage removed the Needs Triage Issue that has not been reviewed by a pandas team member label Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants