import pandas as pd async def map_results(results: list[dict], mapping: dict[str, str]) -> pd.DataFrame: values = list(mapping.values()) if "title" not in values: raise ValueError("title is required in the mapping") if "link" not in values: raise ValueError("link is required in the mapping") if "body" not in values: raise ValueError("body is required in the mapping") mapped_data = [ {mapping.get(key, key): value for key, value in result.items()} for result in results ] result = {"title": [], "link": [], "body": []} for data in mapped_data: result["title"].append(data["title"]) result["link"].append(data["link"]) result["body"].append(data["body"]) return pd.DataFrame(result)