1

We query a df by below code:

json.loads(df.reset_index(drop=True).to_json(orient='table'))

The output is:

{"index": [ 0, 1 ,2, 3, 4],
 "col1": [ "250"],
 "col2": [ "1"],
 "col3": [ "223"],
 "col4": [ "2020-06-12 14:55"]
}

We need the output should be like this:

[ "250", "1", "223", "2020-06-12 14:55"],[.....][.....]
1
  • You can use zip. What would be the values in [.....][.....]? Please add minimal reproducible example Commented Jul 6, 2020 at 4:51

3 Answers 3

2
json.loads(df.reset_index(drop=True).to_json(orient='values')) 

change table into values solved my problem.

Sign up to request clarification or add additional context in comments.

Comments

0

What you call a "json" (there is no such data type) is a Python dictionary. Extract the values for the keys of interest using list comprehension:

x = .... # Your dictionary
[x[col][0] for col in x if col.startswith("col")]
#['250', '1', '223', '2020-06-12 14:55']

1 Comment

json.loads(df.reset_index(drop=True).to_json(orient='values')) change table into values solved my problem.
0

We convert json to dataframe and we remove column name.

pd.Dataframe(json_source,header='False')

Then we convert it to json formate

df.to_json(orient='table')

1 Comment

json.loads(df.reset_index(drop=True).to_json(orient='values')) change table into values solved my problem.

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.