A blog about technical stuff


Jan Schulz

BI Engineer @ kfzteile24.de | Python enthusiast (knitpy, pandas, statsmodels, matplotlib, ggplot, pypandoc) | PhD student @ TU Freiberg (bibliometrics, academic research productivity, social networks, social capital) | Private homepage (de)

Github
Twitter
LinkedIn
Email

Archive | RSS

More functions for working with JSON data / nested structures

I updated the functions in my last blog post (rename the functions and added a few corner cases) and added a new convert_to_dataframe_input function:

# can be a dict or a list of structures
data = {"ID1":{"result":{"name":"Jan Schulz"}},
        "ID2":{"result": {"name":"Another name", "bday":"1.1.2000"}}}

converter_dict = dict(
    names = "result.name",
    bday = "result.bday"
)
import pandas as pd
print(pd.DataFrame(convert_to_dataframe_input(data, converter_dict)))
##   _index      bday         names
## 0    ID1       NaN    Jan Schulz
## 1    ID2  1.1.2000  Another name

The (updated) code can be found in the old blogpost.

comments powered by Disqus