Replies: 2 comments
-
Hello, |
Beta Was this translation helpful? Give feedback.
-
Hello @opalmeira, If you want to do it, you should convert the my_df = pd.read_json("path/to/dictionary.json")
my_dict = my_df.to_dict()
my_bd = benedict(my_dict) or you could directly create the my_bd = benedict.from_json("path/to/dictionary.json") or simply: my_bd = benedict("path/to/dictionary.json") |
Beta Was this translation helpful? Give feedback.
-
Hello,
First I would like to thank you for sharing your program to handle dictionaries.
I installed python-benedict as suggested and am trying to use to manage my complex dictionary which has dictionaries of dictionaries which in turn has lists of dictionaries.
In order to test the program I created a dummy dictionary that is sort of a very simplified version of the target one:
d = {'a':{'b': {'c':[{'z':['e','f']},2,3], 'd':[5,6,7]}}}
d = benedict(df)
And I want to retrieve the value like this:
d["a.b.c[0].z[0]"]
output: 'e'
This works perfectly, but when I tried on my target dictionary I get the error.
My dictionary is loaded like this:
my_dict = pd.read_json("path/to/dictionary.json")
It is actually a json file, so I also tried:
benedict.from_json
But it does not work either
If anyone can help me, I would appreciate it.
Thank you!
0 votes ·
Beta Was this translation helpful? Give feedback.
All reactions