Python: Wie speichern Sie eine JSON -Datei ohne Klammern?Python

Python-Programme
Anonymous
 Python: Wie speichern Sie eine JSON -Datei ohne Klammern?

Post by Anonymous »

Ich versuche, eine JSON -Datei zu generieren, es generiert jedoch mit Klammern, die nicht beabsichtigt sind. Wie kann ich das überwinden?

Code: Select all

import pandas as pd

df = pd.DataFrame({"A": [10],
"B": [20],
"C": [30]})

df.to_json('file.json', orient='records')
< /code>

[b]File.json[/b]

[{"A":10,"B":20,"C":30}]
< /code>

 Erwartete Ausgabe < /strong>: < /p>

 {"A":10,"B":20,"C":30}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post