Skip to content

TypeError: can only concatenate list (not "int") to list #28261

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

Closed
Jasonsey opened this issue Sep 3, 2019 · 5 comments
Closed

TypeError: can only concatenate list (not "int") to list #28261

Jasonsey opened this issue Sep 3, 2019 · 5 comments
Labels
Bug Needs Discussion Requires discussion from core team before further action Nested Data Data where the values are collections (lists, sets, dicts, objects, etc.). Numeric Operations Arithmetic, Comparison, and Logical operations

Comments

@Jasonsey
Copy link

Jasonsey commented Sep 3, 2019

Code Sample, a copy-pastable example if possible

import pandas as pd
a = pd.Series([[12]])
b = a + [222]

Problem description

  1. in pandas version 0.24, the code went well
  2. in pandas version 0.25.1, the code raise TypeError can only concatenate list (not "int") to list
~\AppData\Local\Continuum\anaconda3\envs\test\lib\site-packages\pandas\core\ops\__init__.py in na_op(x, y)
    967         try:
--> 968             result = expressions.evaluate(op, str_rep, x, y, **eval_kwargs)
    969         except TypeError:

~\AppData\Local\Continuum\anaconda3\envs\test\lib\site-packages\pandas\core\computation\expressions.py in evaluate(op, op_str, a, b, use_numexpr, **eval_kwargs)
    220     if use_numexpr:
--> 221         return _evaluate(op, op_str, a, b, **eval_kwargs)
    222     return _evaluate_standard(op, op_str, a, b)

~\AppData\Local\Continuum\anaconda3\envs\test\lib\site-packages\pandas\core\computation\expressions.py in _evaluate_standard(op, op_str, a, b, **eval_kwargs)
     69     with np.errstate(all="ignore"):
---> 70         return op(a, b)
     71

TypeError: can only concatenate list (not "int") to list

Expected Output

no error should be raised

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.6.8.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None

pandas : 0.25.1
numpy : 1.16.3
pytz : 2019.1
dateutil : 2.8.0
pip : 19.0.3
setuptools : 41.0.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.3.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.8.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.3.3
matplotlib : 3.1.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.2.1
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None

@TomAugspurger
Copy link
Contributor

cc @jbrockmendel.

I'm not sure if this is something we can easily support right now.

@TomAugspurger TomAugspurger added the Numeric Operations Arithmetic, Comparison, and Logical operations label Sep 3, 2019
@jbrockmendel
Copy link
Member

@Jasonsey what output are you expecting here? A Series with a single entry that is a list [12, 222]?

@jbrockmendel
Copy link
Member

xref #27911

@Jasonsey
Copy link
Author

Jasonsey commented Sep 9, 2019

@jbrockmendel Sorry for late. The output what I expect here is [12, 222]. And I have demoted the version as a temporary solution

@jbrockmendel jbrockmendel added List-Like Scalars Nested Data Data where the values are collections (lists, sets, dicts, objects, etc.). and removed List-Like Scalars labels Sep 21, 2020
@mroeschke mroeschke added Bug Needs Discussion Requires discussion from core team before further action labels Jul 11, 2021
@xumanru
Copy link

xumanru commented Jan 4, 2022

Same problem.You can try 'apply...'to solve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Discussion Requires discussion from core team before further action Nested Data Data where the values are collections (lists, sets, dicts, objects, etc.). Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

No branches or pull requests

5 participants