0

I currently have a pandas dataframe, I want it to get downloaded when you hit an API endpoint using Falcon. Currently I have following code.

data = df
resp.status = falcon.HTTP_200
resp.stream = data
resp.content_type = 'text/csv'

How can send the contents of my dataframe over the network to so that it gets downloaded when you hit the API endpoint? Any help is Appreciated! Thanks!

howard roark
  • 628
  • 7
  • 27

1 Answers1

-1

First you must transform the DataFrame into something suitable for sending. Easiest is probably to_json(): https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_json.html because JSON is the easiest language to parse in most web clients.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436