etl_programs.py 1.65 KB
Newer Older
Sanjay Krishnan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
'''
Here, you will write programs that transform dataframes
using the functions that you wrote.
'''

def phone():
    '''
    Write an ETL program that results in a
    dataframe with two columns: area_code, phone_number.
    '''
    df = pd.DataFrame([['(408)996-758'],
                      ['+1 667 798 0304'],
                      ['(774)998-758'],
                      ['+1 442 030 9595']],
                      columns=["phoneno"])
    etl = ETL(df)


    #Your code goes here


    return etl.df


def date():
    '''
    Write an ETL program that results in a
    dataframe with three columns: day, month, year.
    The day must be in two-digit format i.e, 01, 08.
    The month must be the full month name, e.g., "May".
    The year must be in YYYY format.
    '''
    df = pd.DataFrame([['03/2/1990'],
                      ['2/14/1964'],
                      ['1990-04-30'],
                      ['7/9/2012'],
                      ['1989-09-13'],
                      ['1994-08-21'],
                      ['1996-11-30'],
                      ['2004-12-23'],
                      ['4/21/2016']]
                      columns=["date"])
    etl = ETL(df)


    #Your code goes here


    return etl.df


def name():
    '''
    Write an ETL program that correctly formats names
    into first_name and last_name.
    '''
    df = pd.DataFrame([['Such,Bob', ''],
                    ['Ann', 'Davis'],
                    ['Dole,Jerry', ''],
                    ['Joan', 'Song']],
                     columns=["first_name", "last_name"])
    etl = ETL(df)


    #Your code goes here


    return etl.df