ArcGIS Pro Jupyter Notebook Pandas Table display

1763
5
Jump to solution
02-17-2022 12:06 PM
ChrisSpadi
New Contributor III

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.

ChrisSpadi_0-1645128243426.png

Haven't been able to find solution

0 Kudos
1 Solution

Accepted Solutions
ChrisSpadi
New Contributor III

 

 

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

 

 

ChrisSpadi_0-1645635765654.png

 

 

View solution in original post

0 Kudos
5 Replies
ChrisSpadi
New Contributor III

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.

0 Kudos
ChrisSpadi
New Contributor III

 

 

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

 

 

ChrisSpadi_0-1645635765654.png

 

 

0 Kudos
Luke_Pinner
MVP Regular Contributor

You're generating new dfs. Use something like

df = df.replace(etc...)
df  # show in notebook

 

0 Kudos
ChrisSpadi
New Contributor III

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).

 

ChrisSpadi_0-1645209005939.png

 

0 Kudos
Luke_Pinner
MVP Regular Contributor

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.

 

0 Kudos