Handle empty dataframes

This commit is contained in:
Peter Vacho 2024-11-25 11:37:12 +01:00
parent 82178b4c6e
commit 50543bd22a
Signed by: school
GPG key ID: 8CFC3837052871B4

View file

@ -19,7 +19,7 @@ def dataframe_to_urlmap(df: pd.DataFrame) -> dict[httpx.URL, set[httpx.URL]]:
:return: A dictionary where the key is a source URL, and the value is a set of target URLs.
"""
urlmap = {}
for source, target in zip(df["source"], df["target"], strict=True):
for source, target in zip(df.get("source", pd.Series()), df.get("target", pd.Series()), strict=True):
source_url = httpx.URL(source)
target_url = httpx.URL(target)
if source_url not in urlmap: