PANDAS to JSON: Changing name of columns

Viewed 844
df = pd.concat([a,b,c,d,e], axis=1, sort=False)

I want to give column names which I usually do to output to Excel as

df.to_excel ("ids.xlsx", index = None, header=['IDs', 'Phases','Versions','Internal Version List','Tests'])

But when I do output to JSON, where should I give the header inputs?

df.to_json ('Export_DataFrame.json', orient='table')
1 Answers

You can set the column names beforehand using:

df.columns = ['IDs', 'Phases','Versions','Internal Version List','Tests']

After you can write the DataFrame to json using:

df.to_json ('Export_DataFrame.json', orient='table')
Related