[Python] how to convert month to frensh month name manuelly using pandas

Discussão em 'Python' iniciado por Stack, Abril 28, 2025.

  1. Stack

    Stack Membro Participativo

    I have this function which convert english month to frensh month :

    def changeMonth(month):
    global CurrentMonth
    match month:
    case "Jan":
    return "Janvier"
    case "Feb":
    return "Février"
    case "Mar":
    return "Mars"
    case "Apr":
    return "Avril"
    case "May":
    return "Mai"
    case "Jun":
    return "Juin"
    case "Jul":
    return "Juillet"
    case "Aug":
    return "Août"
    case "Sep":
    return "Septembre"
    case "Oct":
    return "Octobre"
    case "Nov":
    return "Novembre"
    case "Dec":
    return "Décembre"

    # If an exact match is not confirmed, this last case will be used if provided
    case _:
    return ""


    and i have a pandas col df["month"]= df['ic_graph']['month'].tolist() :

    [​IMG]

    now what i'm looking for is to pass the df["month"] col through the changeMonth function to display the df["month"] in frensh months

    by the way , i do not want to use the

    >>> import locale
    >>> locale.setlocale(locale.LC_ALL, 'fr_FR')


    many thnaks

    Continue reading...

Compartilhe esta Página