ArcPy Data Access Support for numpy.datetime64 and Python datetime

5037
11
04-16-2015 02:44 PM
JoshuaBixby
MVP Esteemed Contributor

Recent questions/discussions on GeoNet got me thinking about an ArcPy Data Access module limitation I hadn't thought about in a while, specifically the lack of date and time support when working with NumPy arrays.  Given where date and time support in NumPy was in 2012 when Esri introduced the ArcPy Data Access module, I can understand why support was missing then, but I think the time is right for them to start supporting it.

I went ahead and created the suggestion on the ArcGIS Ideas site:  ArcPy Data Access Support for numpy.datetime64 and Python datetime.  I also logged an enhancement request with Esri Support:  ENH-000086993: Update the ArcPy Data Access module to include support for numpy.datetime64 and Python datetime.  If you would like to see date and time support for the NumPy-related methods in the ArcPy Data Access module, I encourage you to go promote the idea on ArcGIS Ideas and submit your own use case to Esri Support to have your customer number attached the aforementioned enhancement request.

11 Replies
LorneDmitruk
New Contributor III

I'm reading a view from a non geodatabase Oracle table containing a number of date fields. In addition the view field names also contain spaces and parentheses. So I read the table into a pandas data frame using an sql query to get the field names GDB friendly, convert to a numpy record array and from there into a scratch table in a file GDB.

I have played around using table to table but if I use field maps it takes a really long time to process, the table has over 100 fields as that's what the users want. Also the view has a couple of fields that are not required and I strip them out in the sql query. Unfortunately I don't have control over how the view was created and can't get it changed.

0 Kudos
JamesCrandall
MVP Frequent Contributor

Improper field names sounds like it should be addressed at the database rather than doing a bunch of gymnastics to transform it elsewhere.  That's an easy fix, just order the dba's to fix it.

What if you were to do the pandas DataFrame-to-numpy-to-featureclass/table minus the date fields, create a secondary pandas dataframe with just a "joinable" field and the date fields then Table_To_Table() those separately and join them back to the larger featureclass/table.

We do similar processing using cx_Oracle to integrate non-spatial tables.

0 Kudos