I'm trying to read a jsonl file with Python's pandas but don't know how to deal with a key that's a json.
What I'm doing is:
pd.read_json('jsonfile', lines=True)
And I'm getting something like:
ID COL1 COL2 COL3
0 12047 93947 {'A': '001', 'B': '"002"'}
1 83621 24013 {'H': '101', 'J': 'TTA', 'K': 'TTB'}
Namely, the entries in COL3 are jsons that can have different keys.
How to transform the keys in COL3 in columns? Since some rows will not have values for the new generated columns, I'd ideally prefer to have it like:
ID COL1 COL2 A B H J K
0 12047 93947 '001' '"002"' NA NA NA
1 83621 24013 NA NA '101' 'TTA' 'TTB'