Trying to take output of a code and pass it to another statement.
t = ", ".join(DTYPE)
output = ('data', list), ('freq', str)
Would like to using "output" and pass into the following:
DF_TYPE = numpy.dtype([t)])
DF = numpy.empty(0, dtype=DF_TYPE)
That is, evaluate
DF_TYPE = numpy.dtype([('data', list), ('freq', str)])
DF = numpy.empty(0, dtype=DF_TYPE)
Error received:
Exception has occurred: TypeError
data type not understood
Sample data:
JSON_DATA = {
"data": [
{
"Members": 29,
"period": "2020-06-30",
"TCOC": 5880070,
},
{
"Members": 21,
"period": "2020-03-31",
"TCOC": 5689074,
}
],
"freq": "quarterly"
}
Have tried using exec() and eval() to no avail.