Package to convert nested JSON to dataframes
Project description
JSON to DataFrame Converter
JSON to DataFrame Converter is a Python package designed to transform deeply nested and irregular JSON structures (including lists of dictionaries, nested lists, and complex hierarchies) into meaningful, minimal, and effective DataFrames. It is ideal for use cases where nested JSON needs to be converted into tabular data with preserved parent-child relationships.
Features
- Converts deeply nested and irregular JSONs into DataFrames.
- Minimizes the number of DataFrames generated while maintaining data integrity.
- Preserves parent-child relationships with clear references.
- Handles list elements within any level of the JSON hierarchy.
- Automatically merges certain tables to reduce complexity.
- Removes empty or redundant DataFrames.
Installation
You can install the package directly from PyPI:
pip install json-to-df
Usage
Basic Example [Refer usage.py]
import json_to_df as j2df
# With a dictionary (API output, JSON converted to dictionary)
sample_dict = {
"user": {
"name": "Alice",
"address": {"city": "London", "zip": "SW1A"},
"orders": [
{"id": 1, "items": [{"name": "ItemA", "price": 30}, {"name": "ItemB", "price": 40}]},
{"id": 2, "items": [{"name": "ItemC", "price": 50}]}
]
},
"admin": {"role": "supervisor"}
}
output_2 = j2df.convert(sample_dict, save_excel=False)
for tab_name, table in output_2.items():
print("DataFrame : ", tab_name)
print(table)
Output Example
DataFrame : Refer:Table:1
table_ref id items
0 user__orders 1 [## Refer:Table:2 Index(es): 0, 1 ##]
1 user__orders 2 [## Refer:Table:2 Index(es): 2 ##]
DataFrame : Refer:Table:2
table_ref name price
0 user__orders__listElem:0__items ItemA 30
1 user__orders__listElem:0__items ItemB 40
2 user__orders__listElem:1__items ItemC 50
DataFrame : Refer:Table:0
user__name user__address__city user__address__zip admin__role
1 Alice London SW1A supervisor
Requirements
- Python 3.7+
- pandas >= 1.0.0
Development & Contributions
Contributions are welcome! Feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License.
Author
Maintained by Sourin Karmakar.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file json_to_df-0.0.1.tar.gz.
File metadata
- Download URL: json_to_df-0.0.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65175a66c00f3040b0ff8757a2fafa0838fce60796f57285c96081c8d9a1813f
|
|
| MD5 |
9652c1d073fbacef8903eb6996a95d08
|
|
| BLAKE2b-256 |
9e704b6ba67ee848549e98b62ecdb8b0f338a31ba55e39939f8be15ddd0a5129
|
File details
Details for the file json_to_df-0.0.1-py3-none-any.whl.
File metadata
- Download URL: json_to_df-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90db5b2d32f0d7eeb3cc2abecb7b39ea9d32572bf1569251a4831b2963e9c4ae
|
|
| MD5 |
8279cfe74001c316b6d64330b9759b4e
|
|
| BLAKE2b-256 |
1cd96d7654a303b1db765cd65b79e5b5b8139cf1cdad69b80b1a7ae9611d40e3
|