code/work_data.py
def extract_last_n_from_df(my_df, columns, n):
    """
    Replace the columns in {columns} with their last {n} characters converted to int.
    Args:
        my_df (pd.DataFrame): target DataFrame. Columns will be extracted from it.
        columns (list): contains target column names.
        n (int): number of characters to be extracted.

    Returns:
        pd.DataFrame: target columns have been replace with the last two characters
            of each observation converted to int.
    """
    my_df = my_df.copy()
    for column in columns:
        target = my_df.pop(column)
        target.replace('Cero', '00', inplace=True)
        my_df[column] = target.apply(lambda x: last_n_to_int(x, n))
    return my_df

    Replace the columns in {columns} with their last {n} characters converted to int.
    Args:
        my_df (pd.DataFrame): target DataFrame. Columns will be extracted from it.
        columns (list): contains target column names.
        n (int): number of characters to be extracted.

    Returns:
        pd.DataFrame: target columns have been replace with the last two characters
            of each observation converted to int.
    
Replace the columns in {columns} with their last {n} characters converted to int.
Replace the columns in { columns } with their last { n } characters converted to int .
def extract_last_n_from_df(my_df, columns, n):
    my_df = my_df.copy()
    for column in columns:
        target = my_df.pop(column)
        target.replace('Cero', '00', inplace=True)
        my_df[column] = target.apply(lambda x: last_n_to_int(x, n))
    return my_df
def extract_last_n_from_df ( my_df , columns , n ) : my_df = my_df . copy ( ) for column in columns : target = my_df . pop ( column ) target . replace ( 'Cero' , '00' , inplace = True ) my_df [ column ] = target . apply ( lambda x : last_n_to_int ( x , n ) ) return my_df
Replace the columns in {columns} with their last {n} characters converted to int.
Replace the columns in { columns } with their last { n } characters converted to int .
"""
    Replace the columns in {columns} with their last {n} characters converted to int.
    Args:
        my_df (pd.DataFrame): target DataFrame. Columns will be extracted from it.
        columns (list): contains target column names.
        n (int): number of characters to be extracted.

    Returns:
        pd.DataFrame: target columns have been replace with the last two characters
            of each observation converted to int.
    """
target columns have been replace with the last two characters
of each observation converted to int.
target columns have been replace with the last two characters of each observation converted to int .
pd.DataFrame
my_df
target DataFrame. Columns will be extracted from it.
target DataFrame . Columns will be extracted from it .
columns
contains target column names.
contains target column names .
n
number of characters to be extracted.
number of characters to be extracted .