Extracting lists in a list in pandas
I have an API response that returns a SUDS object, which I then convert to a dict using this:
DICT (campaign)
The problem I have is that I cannot figure out how to convert this list to a usable Dataframe. If I try this:
for_merge_ids = dict(campaigns)
test = pd.DataFrame.from_dict(for_merge_ids)
The lawsuit looks like this:
(campaign){
campaignID = 77705
campaignName = "FLI - Tablet"
campaignBid =
(bidInformation){
biddingStrategy = "Cpc"
cpcBid =
(CPCBid){
cpc = 0
}
cpaBid = None
}
budgetID = 0
remainingDays = 5
status = "RUNNING"
categoryBids =
(ArrayOfCategoryBid){
categoryBid[] =
(categoryBid){
campaignCategoryUID = 0
campaignID = 77705
categoryID = 0
selected = True
bidInformation =
(bidInformation){
biddingStrategy = "Cpc"
cpcBid =
(CPCBid){
cpc = 0
}
cpaBid = None
}
},
(categoryBid){
campaignCategoryUID = 0
campaignID = 77705
categoryID = 0
selected = True
bidInformation =
(bidInformation){
biddingStrategy = "Cpc"
cpcBid =
(CPCBid){
cpc = 0.12
}
cpaBid = None
}
},
(categoryBid){
campaignCategoryUID = 2289648
campaignID = 77705
categoryID = 1676592472
selected = True
bidInformation =
(bidInformation){
biddingStrategy = "Cpc"
cpcBid =
(CPCBid){
cpc = 0
}
cpaBid = None
}
},
(categoryBid){
campaignCategoryUID = 0
campaignID = 77705
categoryID = 0
selected = True
bidInformation =
(bidInformation){
biddingStrategy = "Cpc"
cpcBid =
(CPCBid){
cpc = 0
}
cpaBid = None
}
},
}
}]}
(although I just want the campaign (with the campaign name) and not others (like budget, arrayofcategorybid, etc.)
I have also tried to specify both types of orientation. I get a dataframe, but with each "list" it is repeated and the columns are not understood - like this:
campaign
0 [(campaignID, 4584), (campaignName, Before Clo...
1 [(campaignID, 5304), (campaignName, Before Clo...
2 [(campaignID, 5305), (campaignName, Before Clo...
3 [(campaignID, 5598), (campaignName, After), (e...
4 [(campaignID, 5684), (campaignName, Before far...
5 [(campaignID, 5685), (campaignName, Before far...
Etc..
Can you help me point out how to get the headers of each of these lines and use them in a df style?
thank
+3
source to share