Pivot Table from Anvil Extras with data from Pandas Dataframe

Hello everyone,

I have implemented the Pivot Table module from Anvil Extras in one of my applications. The module is great and works very well with data from the Anvil database, but I can’t get it to work with data from a Pandas dataframe.

This is the code (Server):

@anvil.server.callable
def getpandasdf():
  d = {'col1': [1, 2], 'col2': [3, 4]}
  df = pd.DataFrame(data=d)
  return df

And the Form code:

records = anvil.server.call('getpandasdf')
self.pivot_1.items = [dict(list(r)) for r in records]

Error:

Does anyone of you have any suggestions?

Thank you in advance!

Hi, @Will1, since this is an Anvil Extras question, I would suggest asking about it on the Anvil Extras GitHub page (Discussions · anvilistas/anvil-extras · GitHub ) :slight_smile:

1 Like

@Will1 That error is caused by you attempting to return a dataframe from a server function back to the client.

Only certain object types can be passed to the client and a dataframe is not one of them. I suggest you have a read of:

3 Likes