葡萄酒标签

葡萄酒数据分析

为君一笑 提交于 2020-02-05 07:06:49
引入包,查看数据 import pandas as pd import matplotlib.pyplot as plt # 支持中文 plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签 plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号 read_df = pd.read_csv('winequality-red.csv',sep=';') white_df = pd.read_csv('winequality-white.csv',sep=';') white_df.head() read_df.head() 新增颜色列 import numpy as np # 为红葡萄酒数据框创建颜色数组 color_red = np.repeat(0,read_df.shape[0]) # 为白葡萄酒数据框创建颜色数组 color_white = np.repeat(1,white_df.shape[0]) read_df['color'] = color_red white_df['color'] = color_white 合并红白葡萄酒数据集 wine_df = read_df.append(white_df) wine_df.info() wine_df.to