Search code examples
pythonpandasto-json

How to display json without column names pandas/python?


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"],[.....][.....]

Solution

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

    change table into values solved my problem.