Let's perform a combined exploration of both types of dataframes. Do you remember how we can merge dataframes? If not, I highly recommend pausing here and quickly skimming through Chapter 6, Grouping Datasets:
- Let's see how we can concatenate both dataframes:
df_wines = pd.concat([df_red, df_white])
- Let's also re-shuffle the rows so that it randomizes the data points:
df_wines = df_wines.sample(frac=1.0, random_state=42).reset_index(drop=True)
Note that the drop=True argument resets the indexes to the default integer index.
- Next, we would like to check the first few columns to see whether all of the rows are correctly merged:
df_wines.head()
The output of the preceding code is given as follows:
Figure 12.10 - Output of the df.head(10) code snippet shown earlier
Note that in Figure 12.10, we have correctly populated the columns, wine_category and quality_label.