Closed MSLTrebesch closed 1 year ago
Hello thanks for reporting this, there seems to be a typo in the code causing this issue. It has been fixed for the next release
@nanaeaubry Thanks. Will this be for the next major release or the next patch release? I ask because I need to know how long to wait until I develop a work around. Any recommendations for a work around? I suppose use append? Or is there a better way to export my Pandas dataframe out to another format to input it into edit_features?
Also, the persisting "future warning error" that has always been present even before this bug was filed - is there an issue with my code that causes that, or is that just part of how the API is behaving?
Thanks!
@MSLTrebesch This will go into a beta 2.2.0 release that comes out in beginning of July.
For a workaround you could transform your dataframe into a list of features to pass in instead of the dataframe so it skips that loop. For the future warning I am unsure... that is a weird one. I will look into it and post here again.
@MSLTrebesch So the future warning is because the orient parameter is being set in the code and we had to update that. If you continue to get it after upgrading to the next version when it is released, let us know so we can see why. I am not getting it on my end but I did get a full on error that the orient was wrong. This might be do to dependency upgrades that make it that production is already at the next version where it wasn't a warning anymore but an error now. Thank you for bringing it up to up so we could fix it!
@MSLTrebesch This will go into a beta 2.2.0 release that comes out in beginning of July.
For a workaround you could transform your dataframe into a list of features to pass in instead of the dataframe so it skips that loop. For the future warning I am unsure... that is a weird one. I will look into it and post here again.
@nanaeaubry Thanks for the tip. So, for the dataframe to list (no features, just rows from a dataframe) What does the structure of the list have to look like? Do I need to include a list of column names?
(I'm supposing so, otherwise, how would edit_features know what to do with the items in the list.)
Like this?
dataframe df:
Name Age
0 Tony 35 1 Steve 70 2 Bruce 45 3 Peter 20
import pandas as pd
# Converting dataframe to list
li = [df.columns.values.tolist()] + df.values.tolist()
# Printing list
print(li)
Output:
[[‘Name’, ‘Age’], [‘Tony’, 35], [‘Steve’, 70], [‘Bruce’, 45], [‘Peter’, 20]]
Sorry should have provided some documentation and examples.
Here we have a small guide showing how to use the edit_features method: https://developers.arcgis.com/python/guide/editing-features/#adding-features
You can see an example of what a feature that will have to go into the list of features will look like. We also have methods such as to_feature_collection
in our GeoAccessor class. Since this is a table you can still use the .spatial
namespace but you might be limited in the usability of some methods. It's worth trying though.
Here is some doc for that:
https://developers.arcgis.com/python/guide/introduction-to-the-spatially-enabled-dataframe/#export-options
You might have to do some data conversion to use some methods. Here is a small guide that does that: https://developers.arcgis.com/python/samples/html-table-to-pandas-data-frame-to-portal-item/
Describe the bug I'm using edit_features to add records from a Pandas dataframe (not spatially enabled) to add to a table in a hosted feature service.
I have typically been able to follow this workflow, but am now getting errors when this code runs.
To Reproduce Steps to reproduce the behavior:
result_deleted is a Pandas dataframe (non-spatial)
error:
Expected behavior using edit_features on a table when appending records from a Pandas dataframe had worked in the past, with previous API versions
The "future warning" error was given, but the data updated.
The Circular Reference Detected error is new.
Platform (please complete the following information):