import base64


def csv_download_link(df, filename):
    """Returns a link to download the dataframe as the given filename."""
    csv = df.to_csv(index=False)
    b64 = base64.b64encode(csv.encode()).decode()
    href = f'data:file/csv;base64,{b64}'
    return f'<a href="{href}" download="{filename}">`{filename}`</a>'