-2

Code:

price_dict["Price"] = price_dict["Price"].apply(lambda x : dict(eval(x)) )
df = price_dict['Price'].apply(pd.Series)

Can anyone explain to me the above equations?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    Show some examples of what `price_dict` contains, then it will become clearer what `eval` does. – mcmayer Sep 14 '19 at 19:12
  • 1
    Hello, welcome to StackOverflow. Can you please provide us with enough of your code to create a Minimal, Complete, and Verifiable example.? I would highly suggest that you edit your question following the guidelines of [this StackOverflow article](https://stackoverflow.com/help/how-to-ask). You may also want to take the [tour](https://stackoverflow.com/tour) to get more familiar with SO and what is expected. – Marcello B. Sep 14 '19 at 22:22

2 Answers2

0

eval basically runs python code from a written (string) expression, and dict turns that result (whatever it is) into a python dictionary object, assuming that's possible.

You should read up more on both: eval, dict

Ofer Sadan
  • 11,391
  • 5
  • 38
  • 62
0

You simple google and will find nicely explained Answers:

For eval read this linke

For dict read this link

dict() - The Python dict() is a built-in function that returns a dictionary object or simply creates a dictionary in Python.

eval() - eval() evaluates the passed string as a Python expression and returns the result. For example, eval("1 + 1") interprets and executes the expression "1 + 1" and returns the result (2)

Karn Kumar
  • 8,518
  • 3
  • 27
  • 53