Skip to content

Instantly share code, notes, and snippets.

@aveek22
Created December 28, 2020 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aveek22/cd96bcef996d45db7c03059918b7bc69 to your computer and use it in GitHub Desktop.
Save aveek22/cd96bcef996d45db7c03059918b7bc69 to your computer and use it in GitHub Desktop.
# imports the Pandas library to work in python
import pandas as pd
# Create the data as a list
data = [['Bob', 30], ['Fred', 35], ['Nick', 40]]
# Load the data as a dataframe
df = pd.DataFrame(data=data, columns=['Name','Age'])
# Covnert the dataframe to JSON
json_data = df.to_json(orient="records")
print(json_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment