У меня есть функция, которая перебирает API, чтобы получить результаты и проанализировать их в фрейме данных:
consolidated_branch = DataFrame(columns=['Inventory', 'Item1', 'Item2', 'Results'])
for each_branch in branches:
branch_result = get_branches_details(each_branch) # get_branch_details returns a dataframe
print(branch_result)
# Loop results:
Inventory ... Results
Year ...
2015 51746398 ... 1090532
2016 33864077 ... -6915080
2017 43410104 ... -3224172
2018 48753351 ... -679117
[4 rows x 9 columns]
Inventory ... Results
Year ...
2017 2028092 ... 6100009
2018 2150537 ... 17570443
[2 rows x 9 columns]
......
Как мне объединить все ветви в consolidated_branch
фрейм данных?
Я пробовал:
for each_branch in get_branch_details(branches):
consolidated_branch = concat([consolidated_branch, branch_result], axis=0, ignore_index=True).groupby(["Item1"]).sum()
print(consolidated_branch)
# results
Empty DataFrame
Columns: [Inventory, Item1, Item2, Results]
Index: []
Не уверен, что это правильный способ объединения данных?