Select to view content in your preferred language

Item usage not correctly getting requests

680
5
Jump to solution
03-28-2023 08:37 PM
Ian-Horn
New Contributor II

 

I want to be able to query the number of item requests during a certain time period. If I use:

ap_hits = ap_item.usage(date_range = '6M, as_df = True)

Screenshot 2023-03-28 at 11.25.57 PM.jpg

 But if I uses date_range = '24', '7D', '30D', or '60D' it comes up as None

Screenshot 2023-03-28 at 11.31.04 PM.jpg

As you can see from the '6M' option, I do have requests in the last 7D.  Why can't I do get the requests with specific time dates less than 6 months?

 

0 Kudos
1 Solution

Accepted Solutions
ChristopherCounsell
MVP Regular Contributor

BUG-000155249 has been fixed. Can confirm that returning as data frame now works expected

from arcgis.gis import GIS

gis = GIS("home")

# Replace 'item_id' with the actual ID of the item you want to retrieve
item_id = ''

# Get the item by ID
item = gis.content.get(item_id)

item_hits = item.usage(date_range= '7D', as_df = True)
print(item_hits)

View solution in original post

0 Kudos
5 Replies
ChristopherCounsell
MVP Regular Contributor

BUG-000155249

You can get the usage if you don't return it as a data frame:

testDictionary = item.usage(date_range='30D',as_df=False)

 But then you have to combine them together. I made a spreadsheet from the dict. Another user sums it, example here:

https://community.esri.com/t5/arcgis-api-for-python-questions/the-usage-property-for-an-item-returns...

 

0 Kudos
Ian-Horn
New Contributor II

Thank you,  I will look into this.

0 Kudos
ChristopherCounsell
MVP Regular Contributor

BUG-000155249 has been fixed. Can confirm that returning as data frame now works expected

from arcgis.gis import GIS

gis = GIS("home")

# Replace 'item_id' with the actual ID of the item you want to retrieve
item_id = ''

# Get the item by ID
item = gis.content.get(item_id)

item_hits = item.usage(date_range= '7D', as_df = True)
print(item_hits)

0 Kudos
JoeGuziStarkCountyOH
Occasional Contributor

Greetings,

I just upgraded my notebook runtime to ArcGIS Notebook Python 3 Standard - 9.0. Now when I run udf = Item.usage(date_range='6M', as_df=True), it appears to work, but I get  the following warning:

2024_05_17_12_04_01_ArcGIS_Online_Item_Audit.jpg

any ideas on how to resolve this, or is this a hope and pray the next update to the python api resolves this? Thank you for everything and have a delightful day.

Sincerely,

Joe Guzi

ChristopherCounsell
MVP Regular Contributor

A quick search indicates that pandas is deprecating datetime. Generally suggests a future update will break it...

It's probably worth a new post and discussion as it's a separate question. This post was specific to a failure/bug which has since been fixed. New question specific to pandas/python/datetime might gather more attention.

0 Kudos