I have a variable that stores a single list of tuples.
It looks like this:
builddict = [
('MfgPartNumber', 'ITEM NUMBER'),
('ShortDescription', 'ITEM DESCRIPTION'),
('StdPk', 'PACKAGE QTY'),
('ListPrice', 'LIST PRICE'),
('Cost', 'NET PRICE APRIL 2024')
]
It is dynamically created based on a loop, so the values will vary by output.
I would like to take that list and build a dataframe from it with the first item as the column name, and the second item and the corresponding row.
For Example:
| MfgParNumber | ShortDescription | StdPk |
| ------------ | ------------------- |----- |
| ITEM NUMBER | ITEM DESCRIPTION |PACKAGE QTY| etc...
I tried this, but can't figure out how to apply the column names to it:
DictCols = list(zip(*builddict))[0]
DictData = pd.DataFrame(list(zip(*builddict))[1]).T
print(DictData)