Problem with server module return value

I am successful getting an array of unique values from a pandas column on the server side. I want to return this series to my form code in order to populate a drop-down list. I’m getting an error on the return. I’ve tried converting retval.tolist(), no love.


@anvil.server.callable
def get_column(col):
  file=app_tables.files.get(filetype='MARSYS')['file']
  df=pd.read_csv(io.BytesIO(file.get_bytes()), names=["industry", "top_level", "category", "sub_category", "vendor", "product", "model", "version", "int_serial","int_eth", "int_usb", "modbus", "tech_vendor", "tech_product", "tech_version", "website", "marsys_key", "tech_key"])
  ret_array = pd.Series(df[col].unique)
  
  for n in ret_array:
    print("cat: " + str(n))

I can see the issue, the server-side is unable to serialize the List… I’ve confirmed that I’ve effectively converted the pandas series to a list.

Unfortunately all I can find in the documentation is the valid return types, which I’ve confirmed I am returning. Still looking…

I’m just taking a quick look but here are a couple of suggestions.

unique is a method so you will want to use unique(). Notice the parentheses.

To debug, you can always try inspecting the the type of the value you are trying to return just to see what it is exactly.

2 Likes

Once again - you saved me hours of futility - that works quite nicely.

1 Like