Extracting a list of JSONs and Creating a Dataframe; with Milliseconds to Date format Conversion
Published in
3 min readMay 4, 2023
In this blogpost we’ll see:
- Extracting a list of jsons and converting it into a Pandas dataframe
- Convert milliseconds to date time format
Let’s assume that we have the following list of jsons:
[{"create_dttm": {"$date": 1677264505842}, "update_dttm": {"$date": 1677264505842}, "wo_id": "ABC-63953"},{"create_dttm": {"$date": 1677264505843}, "update_dttm": {"$date": 1677264505843}, "wo_id": "ABC-63954"}]
In order to convert this into a dataframe we can use the from_records
method from Pandas library
import pandas as pd
# Define the list of JSON objects
json_list = [{"create_dttm": {"$date": 1677264505842}, "update_dttm": {"$date": 1677264505842}, "wo_id": "ABC-63953"},
{"create_dttm": {"$date": 1677264505843}, "update_dttm": {"$date": 1677264505843}, "wo_id": "ABC-63954"}]
df = pd.DataFrame.from_records(json_list)
print(df)
Let’s see how the ouput (ie: output1) looks like: