Skip to content

Instantly share code, notes, and snippets.

@thanakijwanavit
Created December 18, 2020 11:01
Show Gist options
  • Save thanakijwanavit/629428f931e0923ed42a29c430c25a27 to your computer and use it in GitHub Desktop.
Save thanakijwanavit/629428f931e0923ed42a29c430c25a27 to your computer and use it in GitHub Desktop.
format a dictionary into list form
import pandas as pd
import json
df = pd.DataFrame({'hello':['1','2','2'], 'world':['1','2','3']})
df
tableDict = df.to_dict(orient='list')
json.dumps(tableDict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment