I have list like this, I loaded from xlsx file
import pandas as pd
travel_df = pd.read_excel('./item.xlsx')
data = travel_df.to_dict('records')
the data like this
data =
[
{
'cat': 'A',
'subCat': 'a1',
},
{
'cat': 'A',
'subCat': 'a2',
},
{
'cat': 'B',
'subCat': 'b1',
},
{
'cat': 'B',
'subCat': 'b2',
},
{
'cat': 'B',
'subCat': 'b3',
},
]
I want to put this into CSV file like this, what is the best and fastest way to do that
A B
--------
a1 b1
a2 b2
b3