Scikit Learn’s train_test_split
is a good one. It will split both numpy arrays and dataframes.
from sklearn.model_selection import train_test_split
train, test = train_test_split(df, test_size=0.2)
More Related Contents:
- How to display pandas DataFrame of floats using a format string for columns?
- Why isn’t my Pandas ‘apply’ function referencing multiple columns working? [closed]
- How to map numeric data into categories / bins in Pandas dataframe
- Group DataFrame in 5-minute intervals
- Why does the following code cant get value of n_fold = 1?
- Filter dataframe rows if value in column is in a set list of values [duplicate]
- Add missing dates to pandas dataframe
- Converting a Pandas GroupBy output from Series to DataFrame
- Pandas: sum DataFrame rows for given columns
- datetime dtypes in pandas read_csv
- Insert a row to pandas dataframe
- Convert unix time to readable date in pandas dataframe
- python – Using pandas structures with large csv(iterate and chunksize)
- How to count the NaN values in a column in pandas DataFrame
- How to convert column with list of values into rows in Pandas DataFrame
- Remove or replace spaces in column names
- pandas dataframe columns scaling with sklearn
- Python Pandas update a dataframe value from another dataframe
- Mapping columns from one dataframe to another to create a new column [duplicate]
- Action with pandas SettingWithCopyWarning
- python dataframe pandas drop column using int
- How to plot two columns of a pandas data frame using points
- which is faster for load: pickle or hdf5 in python
- Return multiple columns from pandas apply()
- Python Pandas – Merge based on substring in string
- Filling in date gaps in MultiIndex Pandas Dataframe
- I want to multiply two columns in a pandas DataFrame and add the result into a new column
- Collapsing rows in a Pandas dataframe if all rows have only one value in their columns
- start index at 1 for Pandas DataFrame
- Multi Index Sorting in Pandas