Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def save_to_vw(filepath: str, X: pd.DataFrame, y: pd.Series=None, chunk_size=1000):
with open(filepath, "w+") as f:
for pos in range(0, len(X), chunk_size):
chunk_X = X.iloc[pos:pos + chunk_size, :]
chunk_y = y.iloc[pos:pos + chunk_size] if y is not None else None
for row in tovw(chunk_X, chunk_y):
f.write(row + "\n")