Select to view content in your preferred language

Calculate number of days in date attribute?

308
1
03-27-2023 07:51 AM
avonmoos
Occasional Contributor

I have a dataset that contains a date attribute and records show date/time. How can I count then number of unique dates while disregarding the time stamp? 

0 Kudos
1 Reply
jcarlson
MVP Esteemed Contributor

If you can load your data into a pandas DataFrame (a "GeoAccessor" in the Python API), it's simple:

from arcgis.features import GeoAccessor

# load layer into dataframe
df = GeoAccessor.from_featureclass('path/to/fc')

# create new date field, dropping time
df['the_date'] = df['your_datetime_field'].dt.date

# get the count
df.groupby('the_date').count()

 

- Josh Carlson
Kendall County GIS
0 Kudos