With the following class:
class Test:
a : str
b : str
and the following data frame:
output = pd.DataFrame(columns=['a', 'b']
how can I convert an array, or list, of class Test into a pandas dataframe with matching columns?
Edit:
Let me add a more concrete example:
class Test:
a: int
b: int
def __init__(self, a: int, b: int):
self.a = a
self.b = b
l = [Test(10, 20), Test(50, 60)]
output = pd.DataFrame(l,
columns=['a', 'b'],
index=range(len(l)))
and the error I get is:
ValueError: Shape of passed values is (2, 1), indices imply (2, 2)