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

to_featureset() is not handling fields with null date values correctly #1819

Closed
tbrobin opened this issue May 2, 2024 · 7 comments
Closed
Assignees
Labels

Comments

@tbrobin
Copy link

tbrobin commented May 2, 2024

I am using to_featureset() to create a featureset from a spatially enabled dataframe and then using edit_features() to edit a feature layer on AGOL. I was having this issue #1693 so I rolled back to a previous version of the API. Now that 2.3.0 is out, I was going to try my luck again.

It seems there is a new bug with to_featureset(). Only some of my features manage to successfully make it to the feature layer using edit_features(). And I am getting this message when they fail.

{'addResults': [{'objectId': 1,
'uniqueId': 1,
'globalId': None,
'success': False,
'error': {'code': 1000,
'description': 'The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 21 ("@applicant_closeout_date"): The supplied value is not a valid instance of data type float. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision.'}}],
'updateResults': [],
'deleteResults': []}

That field is not a float. It is a date with null values mixed in. I did some troubleshooting and it seems to_featureset() is treating that field differently than other date fields in the data with no nulls.

Here is how it treats that field if I remove the null values, and these values will work in a bulk edit using edit_features(adds=featureset.features).

image

Here is how it treats that field if it has null values, and it won't work using edit_features(adds=featureset.features).

image

@tbrobin tbrobin added the bug label May 2, 2024
@nanaeaubry
Copy link
Contributor

@tbrobin Thanks for reporting this, sorry for the delayed response. I will take a look and see where this new error is coming from.
Ill post any updates!

@nanaeaubry nanaeaubry self-assigned this May 13, 2024
@nanaeaubry
Copy link
Contributor

@tbrobin Can you provide us with some reproducible data and code?

@tbrobin
Copy link
Author

tbrobin commented May 13, 2024

Dates.xlsx
``
import pandas as pd
from arcgis.features import GeoAccessor, GeoSeriesAccessor

#path to Dates excel
dates_excel=

nonulls=pd.read_excel(dates_excel,sheet_name='NoNulls')
withnulls=pd.read_excel(dates_excel,sheet_name='WithNulls')

nonulls_fs=nonulls.spatial.to_featureset()
withnulls_fs=withnulls.spatial.to_featureset()

#test feature set with nulls
print(withnulls_fs.features)

#test feature set without nulls
print(nonulls_fs.features)
`

@tbrobin
Copy link
Author

tbrobin commented May 13, 2024

Thanks for looking into this!

@nanaeaubry
Copy link
Contributor

@tbrobin Ok I see the issue, Pandas interprets NaN values as float and not int. Hence why the entire column gets changed to float values when null dates are present.
A workaround for now would be to take all the values resulting from the feature set and type cast them as int.
We are adding a fix in the code for this, thanks for reporting it!

@tbrobin
Copy link
Author

tbrobin commented May 14, 2024

Great! So will this be fixed in the next ArcGIS API Release?

@nanaeaubry
Copy link
Contributor

@tbrobin yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants