Error: Could not load the dataset: Cannot convert non-finite values (NA or inf) to integer by pd.DataFrame.spatial.from_layer
See original GitHub issueDescribe the bug The same code works in Arcpy 2.9/ArcGIS Pro 2.9, and after updated to ArcGIS Pro 3.0/Arcpy 3.0, the code got the below error.
error: ``` _Traceback (most recent call last): File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\arcgis\features\geo_accessor.py”, line 2688, in from_layer return from_layer(layer=layer) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\arcgis\features\geo_io\serviceops.py”, line 187, in from_layer sdf = layer.query(where=query, as_df=True) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\arcgis\features\layer.py”, line 1856, in query df = self._query_df(url, params) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\arcgis\features\layer.py”, line 3308, in _query_df df = df.astype(dtypes) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\pandas\core\generic.py”, line 5799, in astype col.astype(dtype=dtype[col_name], copy=copy, errors=errors) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\pandas\core\generic.py”, line 5815, in astype new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\pandas\core\internals\managers.py”, line 418, in astype return self.apply(“astype”, dtype=dtype, copy=copy, errors=errors) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\pandas\core\internals\managers.py”, line 327, in apply applied = getattr(b, f)(**kwargs) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\pandas\core\internals\blocks.py”, line 591, in astype new_values = astype_array_safe(values, dtype, copy=copy, errors=errors) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\pandas\core\dtypes\cast.py”, line 1309, in astype_array_safe new_values = astype_array(values, dtype, copy=copy) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\pandas\core\dtypes\cast.py”, line 1257, in astype_array values = astype_nansafe(values, dtype, copy=copy) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\pandas\core\dtypes\cast.py”, line 1168, in astype_nansafe return astype_float_to_int_nansafe(arr, dtype, copy) File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\pandas\core\dtypes\cast.py”, line 1213, in astype_float_to_int_nansafe raise IntCastingNaNError( pandas.errors.IntCastingNaNError: Cannot convert non-finite values (NA or inf) to integer
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “<string>”, line 1, in <module> File “C:\Users\hd\AppData\Local\ESRI\conda\envs\arcgispro_py3_clone\lib\site-packages\arcgis\features\geo_accessor.py”, line 2697, in from_layer raise Exception(“Could not load the dataset: %s” % str(e)) Exception: Could not load the dataset: Cannot convert non-finite values (NA or inf) to integer_ ```
Platform (please complete the following information):
- OS: Windows 11
- Python API Version : 2.0.1
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
@sstrack265 You could downgrade the API version to 2.0.0, just know that if you plan on using this environment within ArcGIS pro, it will no longer be compatible. You will have to make/use a different python environment within ArcGIS Pro. The newest version of ArcGIS Pro requires that its python environment has the newest version of the API installed.
Outside of downgrading the package, options are:
I understand neither of these options are entirely possible/advantageous for some workflows.
Do we have any idea of when a 3.1.0 release would be? And is there a suggested work around in the meantime- such as using an older version of Python API?