I am trying to read a dictionary in the below format:
d = \
{
'indent_insert': {1000037121: [('0 - Success',)], 1000037122: [('0 - Success',)]},
'indent_detail_insert': {1000037121: [('0 - Success',)], 1000037122: [('22051 - duplicate key violation error',)]}
}
This is not JSON per say as it has no " around ['0 - Success',)]. The above is being generated from the below code snippets:
key = ['indent_insert','indent_detail_insert']
result = []
indent_lst = ['1000037121','1000037122']
c_indlts_l = [('0-Success'),('22051 - duplicate key violation error')]
c_ind_l = [('0-Success'),('0-Success')]
indtls_results = dict(zip(indent_lst,c_indlts_l))
ind_result = dict(zip(indent_lst,c_ind_l))
result.append(ind_result)
result.append(indtls_results)
d = dict(zip(key,result))
Now I want a dataframe like below:
IndentNo indent_insert indent_details_insert
1000037121 ('0-Success') ('0 - Success')
1000037122 ('0-Success') ('22051 - duplicate key violation error')
In order to achieve the same I am trying the following:
with open(os.path.join(dir_path,f_ind),'r') as f_r:
d = f_r.read()
df = pd.DataFrame.from_dict(d)
I am getting
ValueError: DataFrame constructor not properly called!
What I am missing out here.
dand my output is the dataframe.