(Python2.7.7, pandas0.14.0)
csvデータは『データサイエンティスト用船読本のやつ流用』
import pandas as pd # import matplotlib.pyplot as plt data = pd.read_csv("body_sample.csv") male = data[data["gender"] == "M"] female = data[data["gender"] == "F"] # plt.hist(male["height"].values, color="#5F9BFF", alpha=.5) # plt.hist(female["height"].values, color="#F8766D", alpha=.5) male["height"].hist(color="#5F9BFF", alpha=.5) female["height"].hist(color="#F8766D", alpha=.5) plt.xlabel("height") plt.ylabel("Freq") plt.show()