In [4]:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from pandas import Series,DataFrame
import seaborn as sns

In [5]:
reviews = pd.read_csv("winemag-data_first150k.csv", index_col=0)
reviews.head(3)


Out[5]:
country description designation points price province region_1 region_2 variety winery
0 US This tremendous 100% varietal wine hails from ... Martha's Vineyard 96 235.0 California Napa Valley Napa Cabernet Sauvignon Heitz
1 Spain Ripe aromas of fig, blackberry and cassis are ... Carodorum Selección Especial Reserva 96 110.0 Northern Spain Toro NaN Tinta de Toro Bodega Carmen Rodríguez
2 US Mac Watson honors the memory of a wine once ma... Special Selected Late Harvest 96 90.0 California Knights Valley Sonoma Sauvignon Blanc Macauley

Univariate plotting with pandas 单一变量

df.plot.bar() df.plot.line() df.plot.area() df.plot.hist()


In [7]:
reviews['province'].value_counts().head(10).plot.bar()
plt.show()



In [8]:
(reviews['province'].value_counts().head(10) / len(reviews)).plot.bar()
plt.show()


三分之一的酒来自加尼福尼亚

得分['points']分数越高越好


In [9]:
reviews['points'].value_counts().sort_index().plot.bar()# 条形图
plt.show()



In [10]:
reviews['points'].value_counts().sort_index().plot.line()
plt.show()



In [11]:
reviews['points'].value_counts().sort_index().plot.area()
plt.show()



In [14]:
reviews['points'].plot.hist()# 直方图  Histograms
plt.show()



In [12]:
reviews[reviews['price'] < 200]['price'].plot.hist()
plt.show()



In [13]:
reviews['price'].plot.hist()
plt.show()



In [15]:
reviews[reviews['price'] > 1500]


Out[15]:
country description designation points price province region_1 region_2 variety winery
13318 US The nose on this single-vineyard wine from a s... Roger Rose Vineyard 91 2013.0 California Arroyo Seco Central Coast Chardonnay Blair
34920 France A big, powerful wine that sums up the richness... NaN 99 2300.0 Bordeaux Pauillac NaN Bordeaux-style Red Blend Château Latour
34922 France A massive wine for Margaux, packed with tannin... NaN 98 1900.0 Bordeaux Margaux NaN Bordeaux-style Red Blend Château Margaux

In [ ]: