借鉴的博客地址:http://www.cnblogs.com/skying555/p/5914391.html
需要先下载:uk_rain_2014.csv(英国降雨量统计表)
下载地址:http://data.defra.gov.uk/statistics_2015/env/water/uk_rain_2014.csv
>>> import pandas as pd
>>> df=pd.read_csv("uk_rain_2014.csv")
>>> df.head()
Water Year Rain (mm) Oct-Sep Outflow (m3/s) Oct-Sep Rain (mm) Dec-Feb \
0 1980/81 1182 5408 292
1 1981/82 1098 5112 257
2 1982/83 1156 5701 330
3 1983/84 993 4265 391
4 1984/85 1182 5364 217Outflow (m3/s) Dec-Feb Rain (mm) Jun-Aug Outflow (m3/s) Jun-Aug
0 7248 174 2212
1 7316 242 1936
2 8567 124 1802
3 8905 141 1078
4 5813 343 4313
>>> df.columns
Index([u'Water Year', u'Rain (mm) Oct-Sep', u'Outflow (m3/s) Oct-Sep',
u'Rain (mm) Dec-Feb', u'Outflow (m3/s) Dec-Feb', u'Rain (mm) Jun-Aug',
u'Outflow (m3/s) Jun-Aug'],
dtype='object')
这里列名称过长并且有空格,不利于之后分析,修改列名
注意列名称数目要和输入数据一致,否则报错:
>>> df.columns=["Years"