Skip to content

BUG: Different results from DataFrame.apply and str accessor #38979

Closed
@pLeBlanc93

Description

@pLeBlanc93
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

# Your code here
import pandas as pd

print(pd.__version__)

df = pd.DataFrame(zip('abc', 'def'))
print(df.apply(lambda f: "/".join(f), axis=1))
print(df.apply(lambda f: "/".join(f.str.upper()), axis=1))

Problem description

Using the str accessor gives different results on 1.1.5 and 1.2.x:

1.1.5
0    a/d
1    b/e
2    c/f
dtype: object
0    A/D
1    B/E
2    C/F
dtype: object

1.2.0+22.g6cdb4e7fb
0    a/d
1    b/e
2    c/f
dtype: object
0    A/D
1    A/D
2    A/D
dtype: object

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 6cdb4e7
python : 3.7.9.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 63 Stepping 2, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None

pandas : 1.2.0+22.g6cdb4e7fb
numpy : 1.19.5
pytz : 2020.5
dateutil : 2.8.1
pip : 20.3.3
setuptools : 51.0.0.post20201207
Cython : 0.29.21
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    ApplyApply, Aggregate, Transform, MapRegressionFunctionality that used to work in a prior pandas versionStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions