I am trying to plot a time serie, but I am not sure how to proceed.
My timeserie is a pandas dataframe in the server module, I am trying to return data to the interface like:
return mydf.to_dict()
but I get:
anvil.server.SerializationError: Cannot serialize return value from function. Cannot serialize dictionaries with keys that aren't strings at msg['response']['ave_rev_rating'][Timestamp('2019-03-31 00:00:00+0000', tz='UTC')]
Pandas’s to_datetime is misleadingly named – it actually produces Pandas Timestamp objects. You want to_pydatetime to get actual honest-to-goodness datetime objects!
anvil.server.SerializationError: Cannot serialize return value from function. Cannot serialize dictionaries with keys that aren't strings at msg['response']['ave_rev_rating'][Timestamp('2019-01-13 00:00:00+0000', tz='UTC')]
@meredydd it looks that it cannot handle datetime as well:
anvil.server.SerializationError: Cannot serialize return value from function. Cannot serialize dictionaries with keys that aren't strings at msg['response']['ave_rev_rating'][datetime.datetime(2019, 1, 13, 0, 0, tzinfo=<UTC>)]
It looks extremely painful to represent time series…
Unfortunately, it looks as if you can’t use datetime objects as dict keys on the client side, due to current Skulpt limitations. This may be improving with the next Skulpt update - we’ll keep you posted if it does!