Skip to content

Instantly share code, notes, and snippets.

@fabiom91
Last active February 22, 2022 13:36
Show Gist options
  • Save fabiom91/b42ee04dbe3423a2ae66d02cc3effb52 to your computer and use it in GitHub Desktop.
Save fabiom91/b42ee04dbe3423a2ae66d02cc3effb52 to your computer and use it in GitHub Desktop.
example split data
import pandas as pd
from sklearn.model_selection import train_test_split
# import my data into a dataframe (df)
df = pd.read_csv("mydata.csv")
# random split 60/40% solution / public dataframe
solution, public_df = train_test_split(df,test_size=0.40,random_state=101)
solution.to_csv("solution.csv", index=False)
public_df.to_csv("public.csv", index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment