I think you need `copy`

:

```
train = df.loc[df['group'] != i].copy()
test = df.loc[df['group'] == i].copy()
```

If you modify values in `test`

later you will find that the modifications do not propagate back to the original data (`df`

), and that Pandas does warning.

### Related Contents:

- How to group dataframe rows into list in pandas groupby
- Conditional Replace Pandas
- Convert a Pandas DataFrame to a dictionary
- Python: pandas merge multiple dataframes
- In pandas, is inplace = True considered harmful, or not?
- Replacing blank values (white space) with NaN in pandas
- How to replace text in a string column of a Pandas dataframe?
- Best way to join / merge by range in pandas
- Pandas dataframe get first row of each group
- Pandas DataFrame to List of Dictionaries
- Convert Column to Date Format (Pandas Dataframe)
- Pretty Printing a pandas dataframe
- Find column name in pandas that matches an array
- How to check if any value is NaN in a Pandas DataFrame
- How to calculate mean values grouped on another column in Pandas
- Pandas Timedelta in Days
- Progress indicator during pandas operations
- Pandas DataFrame concat vs append
- How to insert pandas dataframe via mysqldb into database?
- Pandas: Cast column to string does not work
- How to concatenate two dataframes without duplicates?
- Constructing a co-occurrence matrix in python pandas
- Python: Random selection per group
- Pandas DataFrame column to list [duplicate]
- Suppressing scientific notation in pandas? [duplicate]
- How to plot multiple dataframes in subplots
- Create a day-of-week column in a Pandas dataframe using Python
- Combining two Series into a DataFrame in pandas
- Return multiple columns from pandas apply()
- Get first row value of a given column
- Putting many python pandas dataframes to one excel worksheet
- Extract string from a dataframe comparing to a list
- How to use Pandas rolling_* functions on a forward-looking basis
- What techniques can be used to measure performance of pandas/numpy solutions
- How can repetitive rows of data be collected in a single row in pandas?
- Merging two dataframes based on a date between two other dates without a common column
- No numeric types to aggregate – change in groupby() behaviour?
- Select row by max value in group in a pandas dataframe
- Seaborn ValueError: zero-size array to reduction operation minimum which has no identity
- How to drop unique rows in a pandas dataframe?
- LabelEncoder: TypeError: ‘>’ not supported between instances of ‘float’ and ‘str’
- Split pandas dataframe in two if it has more than 10 rows
- Pandas Dataframe Find Rows Where all Columns Equal
- plotting a histogram on a Log scale with Matplotlib
- Pandas get the age from a date (example: date of birth)
- Loading multiple csv files of a folder into one dataframe
- Pandas rolling values
- Output data from all columns in a dataframe in pandas [duplicate]
- start index at 1 for Pandas DataFrame
- ValueError: Shape of passed values is (1, 6), indices imply (6, 6)