Data Tables and Pandas

I have a table where each row is a sensitive report for a given company. Many company’s reports are stored in this one table. In the table is an account_ID. In my User’s table, I include an account_ID field to denote which company’s reports a user can see. Some users will need to see reports from multiple companies (like with a private equity firm, wanting to see the reports for all of their portfolio companies).

From the client, I place a call to a server function to ‘filter’ the data table to return to a repeating panel. I use Pandas on the server so I can use the account_id.isin(list of user’s account_ids) and it filters very nicely and quickly. Problem is, I don’t know a good way of returning that filtered dataframe back to the client. Does anyone know how to convert that and return it as an iterable object that my repeating panel will understand? I have a media object in there too, the actual .pdf report, so that needs to stay intact.

Any help much appreciated.

Can the filter be expressed using Anvil’s query features? If so, then Anvil can deliver the iterable you want.

The only other way to return an iterable across the wire is to return a list, e.g., a list of dicts.

1 Like

That might be the only option.

None of the query operators works because I have to use the x in(y) function and it simply did not seem to like that in any form

Try Anvil’s query functionality with: account_ID=q.any_of([List, of, values, here])

Have you tried returning the filtered dataframe as a list of tuples. Try pandas.to_records method. Then you can insert the filtered records into the items of the repeating panel.

1 Like