The syntax for returning the usage of an item in ArcGIS online for 30 days and 60 days returns None or Empty Dataframe when the as_df paramater is True. I am using version 2.0.1 of the API and have tried it in desktop Jupyter notebook, ArcGIS Online Jupyter notebook, and standalone script.
my_content = gis.content.search(query="owner:" + gis.users.me.username, max_items=15)
for item in my_content:
df_usage30 = item.usage(date_range='30D', as_df=True)
df_usage60 = item.usage(date_range='60D', as_df=True)
print(df_usage30, " ",df_usage60)
This is for all kinds of items and ones that have been created recently and I know are being used. You can see the usage statistics in the Usage panel of the item description in AGOL. When I use the item.numViews property on the same items, it returns the correct views (I know views and usage are different).
All I can find are posts about how this is an issue, bugs that don't seem to be resolved, and Github issues that claim they are resolved. Any guidance about what I should be doing differently are welcome..
Here is one of the things I have found regarding this subject:
item.usage() returns None when using the default output (as_df=True). Version 2.0.0 · Issue #1205 · Esri/arcgis-python-api · GitHub