2
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')
2
  • 1
    set the names beforehand df.columns = ['IDs', 'Phases','Versions','Internal Version List','Tests'], then df.to_json(....) Commented May 13, 2020 at 9:42
  • Can you write this as answer so that I mark it as completed and then it would helpful for others too. Thanks Commented May 13, 2020 at 10:40

1 Answer 1

1

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')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.