pandas to json
>>> df.to_json(orient='records')
'[{"col 1":"a","col 2":"b"},{"col 1":"c","col 2":"d"}]'
pandas to json
>>> df.to_json(orient='records')
'[{"col 1":"a","col 2":"b"},{"col 1":"c","col 2":"d"}]'
export python pandas dataframe as json file
df.to_json(r'C:UsersRonDesktopFile Name.json', orient='index')
#if you want to just convert to a json file, then omit the file path and enter only file name.
convert dataframe to json
dictionary_varibale = [
dict([
(colname, row[i])
for i,colname in enumerate(df.columns)
])
for row in df.values
]
print(json.dumps(dictionary_varibale))
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us