I am trying to display a table in Jupyter Notebook with Panadas.
Goal
Update Fields, 1 to Yes, and Null/Nan to blank AND hide OBJECT ID, ShapeLength then export PNG if possible of styled Panda table.
Seems the df display is temporary.
Haven't been able to find solution
Solved! Go to Solution.
import pandas as pd
from arcgis.features import GeoAccessor, GeoSeriesAccessor
data = "C://Users//cspadi//Desktop//Water Design Environmental//Design Environmental.gdb//UnionWater"
df = pd.DataFrame.spatial.from_featureclass(data)
df.sort_values("ProjectSection", inplace=True)
df.drop(['OBJECTID', 'SHAPE'], axis=1, inplace=True)
df.style.hide_index()
Was able to figure it out after looking into the pandas documentation, probably a cleaner way to achieve it but this works if anyone is interested
I am aware the pandas replace and drop are not permanently updating the fc table, but would like if I could update the cells and hide the fields at the same time so both appear on one table.
Goal would be to export the panada table as PDF or PNG, if it doesn't require too much scripting? Any ideas are welcome. thanks.
import pandas as pd
from arcgis.features import GeoAccessor, GeoSeriesAccessor
data = "C://Users//cspadi//Desktop//Water Design Environmental//Design Environmental.gdb//UnionWater"
df = pd.DataFrame.spatial.from_featureclass(data)
df.sort_values("ProjectSection", inplace=True)
df.drop(['OBJECTID', 'SHAPE'], axis=1, inplace=True)
df.style.hide_index()
Was able to figure it out after looking into the pandas documentation, probably a cleaner way to achieve it but this works if anyone is interested
You're generating new dfs. Use something like
df = df.replace(etc...)
df # show in notebook
replace and drop updates dont appear as before and the graphic df becomes text df with same issue (shows object ID, Shape, and doesn't update values).
You know that pandas/geopandas operations generally return a new dataset and don't alter the existing dataset...? Unless that method accepts an inplace argument.
So
df = df.replace(etc...) # returns new dataset, assigns it to new df variable.
df.drop(etc...) # returns new dataset, isn't assigned to any variable so just goes out of scope and is deleted
df # still has the objectid, shape cols because you haven't altered the df variable.