def train_test_split()

in Python/length_of_stay_utils.py [0:0]


def train_test_split(id, table, train_table, p, connection_string):
    pyodbc_cnxn = pyodbc.connect(connection_string)
    pyodbc_cursor = pyodbc_cnxn.cursor()
    pyodbc_cursor.execute("DROP TABLE if exists {};".format(train_table))
    pyodbc_cursor.execute("SELECT {} INTO {} FROM {} WHERE ABS(CAST(BINARY_CHECKSUM(eid, NEWID()) as int)) % 100 < {} ;".format(id, train_table, table, p))
    pyodbc_cursor.close()
    pyodbc_cnxn.commit()
    pyodbc_cnxn.close()