A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/44923 below:

values cannot be losslessly cast to int64` for integer strings · Issue #44923 · pandas-dev/pandas · GitHub

Pandas version checks Reproducible Example
import pandas as pd
pd.Series(['1', '2'], dtype='int64')
Issue Description
C:\Users\a\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\core\numeric.py:2446: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  return bool(asarray(a1 == a2).all())
Traceback (most recent call last):
  File "C:\Users\a\AppData\Roaming\JetBrains\PyCharmCE2021.3\scratches\scratch_3.py", line 2, in <module>
    pd.Series(['1', '2'], dtype='int64')
  File "f:\prog\pandas\pandas\core\series.py", line 450, in __init__
    data = sanitize_array(data, index, dtype, copy)
  File "f:\prog\pandas\pandas\core\construction.py", line 583, in sanitize_array
    subarr = _try_cast(data, dtype, copy, raise_cast_failure)
  File "f:\prog\pandas\pandas\core\construction.py", line 768, in _try_cast
    subarr = maybe_cast_to_integer_array(arr, dtype)
  File "f:\prog\pandas\pandas\core\dtypes\cast.py", line 2100, in maybe_cast_to_integer_array
    raise ValueError(f"values cannot be losslessly cast to {dtype}")
ValueError: values cannot be losslessly cast to int64
Expected Behavior

I expect
pd.Series(['1', '2'], dtype='int64')
to work fine and return a Series object with dtype int64, just like how
pd.Series(['1', '2'], dtype='float64')
returns a float64 Series.

Installed Versions INSTALLED VERSIONS

commit : 39ccb35
python : 3.10.1.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19043
machine : AMD64
processor : Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 0+untagged.1.g39ccb35
numpy : 1.21.4
pytz : 2021.3
dateutil : 2.8.2
pip : 21.3.1
setuptools : 59.5.0
Cython : 0.29.25
pytest : 6.2.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.0.2
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 7.29.0
pandas_datareader: None
bs4 : 4.10.0
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.5.0
numexpr : None
odfpy : None
openpyxl : 3.0.9
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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4