def METHOD_NAME(df_elec: pd.DataFrame) -> pd.DataFrame:
    """Select necessary columns from the electricity mix, and select rows corresponding to the UK.
    Parameters
    ----------
    df_elec : pd.DataFrame
        Data from the main table of the electricity mix dataset.
    Returns
    -------
    df_elec : pd.DataFrame
        Selected columns and rows from the electricity mix data.
    """
    df_elec = df_elec.copy()
    # Select columns and rename them conveniently.
    elec_columns = {
        "country": "country",
        "year": "year",
        "coal_generation__twh": "coal_generation",
        "gas_generation__twh": "gas_generation",
        "oil_generation__twh": "oil_generation",
        "hydro_generation__twh": "hydro_generation",
        "nuclear_generation__twh": "nuclear_generation",
        "other_renewables_including_bioenergy_generation__twh": "other_renewables_generation",
        "solar_generation__twh": "solar_generation",
        "total_generation__twh": "total_generation",
        "wind_generation__twh": "wind_generation",
        "total_net_imports__twh": "net_imports",
    }
    # Select necessary columns from electricity mix dataset.
    df_elec = df_elec[list(elec_columns)].rename(columns=elec_columns)
    # Select UK data from Ember dataset.
    df_elec = df_elec[df_elec["country"] == "United Kingdom"].reset_index(drop=True)
    return df_elec