Я собираю информацию о монетах.Мне нужно добавить все записанные данные в один Dataframe.
У меня есть следующий код:
import bs4 as bs
import urllib.request
import pandas as pd
def scraping_func(coin_id):
"""
This function recives "coins_id" from "coins_to_scrape list".
It scrapes all data that I need and puts it to "df" Dataframe
Then it saves this Dataframe to excel file (%coin_id%.xlsx)
The last lines of the function are: (I cut my code because it's big)
"""
df = df[['Country', 'Value', 'Year', 'Metal', 'Marks', 'Mintage', 'Krause', 'Price', 'Quality', 'Details', 'Avers', 'Revers', 'Gcoins_link']]
excel_name = '{}.xlsx'.format(coin_id)
df.to_excel(excel_name)
for i in dfs:
dfs = df.append(dfs, ignore_index=True)
dfs.to_excel('adfasdf.xlsx')
coins_to_scrape = [514, 515, 179080, 45518, 521, 111429] # The list of ID that I need to scrape
for i in coins_to_scrape: # For each coin in the list
scraping_func(i) # call the "scraping_func" function
Отлично работает.Но этот код создает отдельный документ Excel для каждой монеты, которые я передаю в функцию.Но есть тысячи монет для очистки, поэтому я хотел бы добавить каждый Dataframes к одному, а затем сохранить его в файл Excel.
Я пытался найти решение в интернете, но не смог.