I am getting JSON-Data from the AzureDevOps-API and I want to save the data in a csv-file with the JSON-Keys as column-names. I have the following code:
Can’t see everything, but it seems to me that you have some extra structure in your JSON data which Pandas isn’t expecting. Can you post a small example of the JSON data you’re working with? What are you expecting your column headers to be? I’d guess id, name, url, etc, in which case you need to extract the values associated with the repository key.
Your post doesn’t show if there is any problem or what it might be. But it appears that you have a deeply nested structure, which is kind of problematic and may not be very suitable for a pandas DataFrame.
If you have a simple structure like:
To convert a deeply nested struct to a DataFrame, you either have to do this in separate steps - first extracting the pieces you want - or you use pandas.json_normalize or you have to use extra tools, like the flatten_json library (which is also not trivial to use in this case, since your nesting mixes dicts and list types).
I would suggest you tinker a bit with some simpler dictionaries first (dicts that contains other dicts and lists) and see how pandas converts those into DataFrames. This may show you a way to handle your original complex dictionary.
You could also do a google search for “pandas and deeply nested structs” - which will bring up some tutorials in this area.