adwib
adwib

Reputation: 53

How can I download a json Dataframe in Google Colab?

I've been working with a dataframe in google colab, and i convert it to a json format using df.to_json(), now i stuck on how to download it into my local disk (or google drive). i found the answers but in csv format, not json.

Any help is appreciated - thanks!

Upvotes: 0

Views: 4465

Answers (1)

Bob Smith
Bob Smith

Reputation: 38589

You can proceed in steps: 1) save the output of to_json() to a file on the Colab backend. Then, use the built-in download helper

from google.colab import files files.download('colab_file_name')

Here's a complete example that starts with a randomly generated DataFrame:

https://colab.research.google.com/drive/1K95vU0gUJW4iJ4FaHxZ1HSQguOP1flEg

Upvotes: 1

Related Questions