How to send a pandas dataframe using POST method and receive it in Hug/other REST API framework? pickle.loads fails to unpickle after sending
问题 How to send a pandas DataFrame using a POST method? For example, the following hug server listens to a POST requests and responds with a pickled pandas DataFrame: import hug import pickle import traceback import pandas as pd @hug.post() def call(pickle_dump): print(type(pickle_dump)) try: df = pickle.loads(pickle_dump) return pickle.dumps(df.iloc[0]) except: print(traceback.format_exc()) return pickle.dumps(pd.DataFrame()) When the following POST request is made: import requests import pandas