"""Writing datasets back to disk.""" from pathlib import Path def save_dataframe(df, path, index=False): """Write ``df`` to an Excel file, creating the parent folder if needed.""" path = Path(path) path.parent.mkdir(parents=True, exist_ok=True) df.to_excel(path, index=index) return path