from datetime import datetime, date
from dateutil.relativedelta import relativedelta

import pandas as pd

# Just a dummy simulation of the example you provided
my_string_dates = ["201912", "201312", "201512"]
df = pd.DataFrame({"my_string_dates": my_string_dates})

# Define a simple function to return the last day of the month in a given year from the given string format
def get_last_day_of_month_from_ym_string(year_month_string: datetime) -> date:
    """
    Expects string containing date in the YYYYMM format and converts it into the last day of the month.
    """
    return (
        datetime.strptime(year_month_string, "%Y%m")
        + relativedelta(months=+1, seconds=-1)
    ).date()


if __name__ == "__main__":

    # Apply the created function to get the last day of the month on your pandas df
    df["new_dates"] = df.apply(
        lambda x: get_last_day_of_month_from_ym_string(
            year_month_string=x["my_string_dates"]
        ),
        axis=1,
    )
    # This will convert the dates into the format you desired and store it into the new column
    df["new_dates_in_desired_format"] = df["new_dates"].apply(
        lambda x: datetime.strftime(x, "%d-%m-%Y")
    )

    # Just a placeholder to put breakpoint on if you wish to run the entire code in debug mode
    print("end")
