preprocessing.py
def split_df(df):

    '''
    Splits dataframe into train, validate, and test - 70%, 20%, 10% respectively.
    Prints out the percentage shape and row/column shape of the split dataframes.
    Returns train, validate, test.
    '''

    # Import to use split function, can only split two at a time
    from sklearn.model_selection import train_test_split

    # First, split into train + validate together and test by itself
    # Test will be %10 of the data, train + validate is %70 for now
    # Set random_state so we can reproduce the same 'random' data
    train_validate, test = train_test_split(df, test_size = .10, random_state = 666)

    # Second, split train + validate into their seperate dataframes
    # Train will be %70 of the data, Validate will be %20 of the data
    # Set random_state so we can reproduce the same 'random' data
    train, validate = train_test_split(train_validate, test_size = .22, random_state = 666)

    # These two print functions allow us to ensure the date is properly split
    # Will print the shape of each variable when running the function
    print("train shape: ", train.shape, ", validate shape: ", validate.shape, ", test shape: ", test.shape)

    # Will print the shape of each variable as a percentage of the total data set
    # Variable to hold the sum of all rows (total observations in the data)
    total = df.count()[0]
    
    #calculating percentages of the split df to the original df
    train_percent = round(((train.shape[0])/total),2) * 100
    validate_percent = round(((validate.shape[0])/total),2) * 100
    test_percent = round(((test.shape[0])/total),2) * 100
    
    print("\ntrain percent: ", train_percent, ", validate percent: ", validate_percent, 
            ", test percent: ", test_percent)

    return train, validate, test

    Splits dataframe into train, validate, and test - 70%, 20%, 10% respectively.
    Prints out the percentage shape and row/column shape of the split dataframes.
    Returns train, validate, test.
    
Splits dataframe into train, validate, and test - 70%, 20%, 10% respectively.
Prints out the percentage shape and row/column shape of the split dataframes.
Returns train, validate, test.
Splits dataframe into train validate and test - 70% 20% 10% respectively . Prints out the percentage shape and row / column shape of the split dataframes . Returns train validate test .
def split_df(df):
    from sklearn.model_selection import train_test_split
    train_validate, test = train_test_split(df, test_size = .10, random_state = 666)
    train, validate = train_test_split(train_validate, test_size = .22, random_state = 666)
    print("train shape: ", train.shape, ", validate shape: ", validate.shape, ", test shape: ", test.shape)
    total = df.count()[0]
    train_percent = round(((train.shape[0])/total),2) * 100
    validate_percent = round(((validate.shape[0])/total),2) * 100
    test_percent = round(((test.shape[0])/total),2) * 100
    print("\ntrain percent: ", train_percent, ", validate percent: ", validate_percent, 
            ", test percent: ", test_percent)
    return train, validate, test
def split_df ( df ) : from sklearn . model_selection import train_test_split train_validate , test = train_test_split ( df , test_size = .10 , random_state = 666 ) train , validate = train_test_split ( train_validate , test_size = .22 , random_state = 666 ) print ( "train shape: " , train . shape , ", validate shape: " , validate . shape , ", test shape: " , test . shape ) total = df . count ( ) [ 0 ] train_percent = round ( ( ( train . shape [ 0 ] ) / total ) , 2 ) * 100 validate_percent = round ( ( ( validate . shape [ 0 ] ) / total ) , 2 ) * 100 test_percent = round ( ( ( test . shape [ 0 ] ) / total ) , 2 ) * 100 print ( "\ntrain percent: " , train_percent , ", validate percent: " , validate_percent , ", test percent: " , test_percent ) return train , validate , test
Splits dataframe into train, validate, and test - 70%, 20%, 10% respectively.
Splits dataframe into train validate and test - 70% 20% 10% respectively .
'''
    Splits dataframe into train, validate, and test - 70%, 20%, 10% respectively.
    Prints out the percentage shape and row/column shape of the split dataframes.
    Returns train, validate, test.
    ''' # Import to use split function, can only split two at a time # First, split into train + validate together and test by itself # Test will be %10 of the data, train + validate is %70 for now # Set random_state so we can reproduce the same 'random' data # Second, split train + validate into their seperate dataframes # Train will be %70 of the data, Validate will be %20 of the data # Set random_state so we can reproduce the same 'random' data # These two print functions allow us to ensure the date is properly split # Will print the shape of each variable when running the function # Will print the shape of each variable as a percentage of the total data set # Variable to hold the sum of all rows (total observations in the data) #calculating percentages of the split df to the original df
df