import base64


def get_download_link_df_to_csv(df, filename):
    """Returns a link allowing given pandas dataframe to be downloaded as csv.

    Args:
        df: pandas dataframe
        filename: str, name of file
                  downloaded file will be <filename>.csv

        Returns:
            url href for use in markdown, to allow file to be downloaded

    """
    csv = df.to_csv(index=False)
    # strings <-> bytes conversions
    b64 = base64.b64encode(csv.encode()).decode()
    href = f'<a href="data:file/csv;base64,{b64}" download="{filename}.csv"'\
           f'>Download data as csv file</a>'

    return href