1

I have a dict(image attached below): [1]: https://i.sstatic.net/n3SYv.png

The keys of the dict is a dataframe. When trying to upload this dict to json I had to convert column a to string type from interval type. But when I want to use the json I want to convert the values of column a back to interval type. Below are the things I've tried:

k = dict.keys()
for keys in k:
   dict[keys]["a"] = dict[keys]["a"].astype("interval")

But it throws the below error: TypeError: type <class 'str'> with value (-inf, -9999999.0] is not an interval

Can you please help me with the way to convert column a values from string to Interval types?

1
  • I think this question has been answered already but without inf: stackoverflow.com/questions/65295837/… inf can be converted with np.array([np.inf]).astype(int)[0] or math.inf (or -math.inf for negative infinity) Commented Jan 3, 2023 at 16:11

1 Answer 1

-1

(See Security of Python's eval() on untrusted strings?)

>>> class Foo(object):
...     pass
... 
>>> eval("Foo")
<class '__main__.Foo'>
Sign up to request clarification or add additional context in comments.

1 Comment

You are only looking at the question title, and not the question details. They are not asking for arbitrary conversions.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.