I have one data frame with row entries and column names. I also have a class defined with attributes (class attribute names are different from dataframe columns).
Now the requirement is to create objects of that class per record from the dataframe and the final list of objects should be output
Class A:
AA, AB, AC....etc
dataframe:
A B c ...
1 2 3 ...
1 2 3 ...
How to avoid column names and start creating objects?
I have tried using this code:
Aobjs = [A(**kwargs) for kwargs in dataframe.to_dict(orient='records')]
df1 = pd.DataFrame(...)) Also, it would be more helpful for you to show us an actual DataFrame with the desired result from the simplified sample. (result = pd.DataFrame...) Otherwise, it will be very difficult to help you. Minimal, Reproducible Example