import sys
!"{sys.executable}" -m pip install --upgrade pandas
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x10ebfd780>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/pandas/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x10ebfd828>: Failed to establish a new connection: [Errno 51] Network is unreachable')': /simple/pandas/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x10ebfd898>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')': /simple/pandas/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x10ebfd550>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')': /simple/pandas/ Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x10ebfd470>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')': /simple/pandas/ Requirement already up-to-date: pandas in /usr/local/lib/python3.7/site-packages (0.25.3) Requirement already satisfied, skipping upgrade: numpy>=1.13.3 in /usr/local/lib/python3.7/site-packages (from pandas) (1.14.5) Requirement already satisfied, skipping upgrade: pytz>=2017.2 in /usr/local/lib/python3.7/site-packages (from pandas) (2018.5) Requirement already satisfied, skipping upgrade: python-dateutil>=2.6.1 in /usr/local/lib/python3.7/site-packages (from pandas) (2.7.3) Requirement already satisfied, skipping upgrade: six>=1.5 in /usr/local/lib/python3.7/site-packages (from python-dateutil>=2.6.1->pandas) (1.11.0)
import pandas as pd
tables = pd.read_html("https://bit.ly/2TpCEWe")
type(tables)
list
len(tables)
1
df = (tables[0]
.drop(['STATION_ID', 'STATION_NM',
'Q', 'Q.1', 'Q.2', 'Q.3', 'D'], axis=1)
.dropna())
df = df[~df['DATE_OBS'].str.startswith("1948")].copy()
%matplotlib inline
df[:365].plot()
<matplotlib.axes._subplots.AxesSubplot at 0x114338a90>
df[:3650].plot()
df[:3650].rolling(window=30).mean().plot()
<matplotlib.axes._subplots.AxesSubplot at 0x1140a5c50>
df['TMPMN'].rolling(window=365, center=True).mean().plot()
df['TMPMN'].rolling(window=3650, center=True).mean().plot()
<matplotlib.axes._subplots.AxesSubplot at 0x1146580b8>
# df['TMPMN'].rolling(window=365, center=True).mean().plot()
df['TMPMN'].rolling(window=3650, center=True).mean().plot()
<matplotlib.axes._subplots.AxesSubplot at 0x1146c51d0>
df['DATE_OBS'] = pd.to_datetime(df['DATE_OBS'])
df.set_index('DATE_OBS', inplace=True)
df
TMPMAX | TMPMIN | TMPMN | PRECIP | |
---|---|---|---|---|
DATE_OBS | ||||
1949-01-01 | -2.1 | -6.7 | -4.2 | 0.0 |
1949-01-02 | -0.5 | -6.7 | -1.2 | 4.2 |
1949-01-03 | 1.1 | -2.1 | -0.7 | 0.0 |
1949-01-04 | 3.3 | 0.9 | 2.3 | 0.0 |
1949-01-05 | 4.0 | -0.9 | 1.1 | 0.8 |
... | ... | ... | ... | ... |
2006-10-27 | 8.7 | 2.7 | 5.6 | 0.3 |
2006-10-28 | 11.0 | 4.1 | 8.2 | 0.3 |
2006-10-29 | 4.6 | 1.4 | 2.4 | 0.5 |
2006-10-30 | 1.8 | -1.9 | -0.7 | 3.5 |
2006-10-31 | 1.3 | -7.7 | -3.0 | 0.0 |
21121 rows × 4 columns
# df['TMPMN'].rolling(window=365, center=True).mean().plot()
df['TMPMN'].rolling(window=3650, center=True).mean().plot()
<matplotlib.axes._subplots.AxesSubplot at 0x11474a4e0>
# df['TMPMN'].rolling(window=365, center=True).mean().plot()
df[:365]['TMPMN'].rolling(window=30, center=True).mean().plot()
<matplotlib.axes._subplots.AxesSubplot at 0x1148bcda0>
df["1949"]
TMPMAX | TMPMIN | TMPMN | PRECIP | |
---|---|---|---|---|
DATE_OBS | ||||
1949-01-01 | -2.1 | -6.7 | -4.2 | 0.0 |
1949-01-02 | -0.5 | -6.7 | -1.2 | 4.2 |
1949-01-03 | 1.1 | -2.1 | -0.7 | 0.0 |
1949-01-04 | 3.3 | 0.9 | 2.3 | 0.0 |
1949-01-05 | 4.0 | -0.9 | 1.1 | 0.8 |
... | ... | ... | ... | ... |
1949-12-27 | 0.1 | -2.8 | -0.8 | 4.2 |
1949-12-28 | -0.1 | -9.8 | -3.9 | 3.1 |
1949-12-29 | -9.3 | -27.0 | -21.4 | 0.9 |
1949-12-30 | -20.9 | -27.5 | -23.9 | 0.2 |
1949-12-31 | -15.6 | -21.7 | -18.6 | 0.2 |
365 rows × 4 columns
df["1949-01"]
TMPMAX | TMPMIN | TMPMN | PRECIP | |
---|---|---|---|---|
DATE_OBS | ||||
1949-01-01 | -2.1 | -6.7 | -4.2 | 0.0 |
1949-01-02 | -0.5 | -6.7 | -1.2 | 4.2 |
1949-01-03 | 1.1 | -2.1 | -0.7 | 0.0 |
1949-01-04 | 3.3 | 0.9 | 2.3 | 0.0 |
1949-01-05 | 4.0 | -0.9 | 1.1 | 0.8 |
1949-01-06 | -0.8 | -3.2 | -2.3 | 0.0 |
1949-01-07 | -0.6 | -5.1 | -3.4 | 0.0 |
1949-01-08 | 0.5 | -3.0 | -0.6 | 1.7 |
1949-01-09 | 0.8 | -1.6 | -0.6 | 0.0 |
1949-01-10 | -1.1 | -4.2 | -2.5 | 1.6 |
1949-01-11 | -3.0 | -5.3 | -4.3 | 0.0 |
1949-01-12 | -3.3 | -8.4 | -5.8 | 0.0 |
1949-01-13 | -4.8 | -10.2 | -6.8 | 0.2 |
1949-01-14 | -1.0 | -5.7 | -2.5 | 0.0 |
1949-01-15 | -1.9 | -3.2 | -2.9 | 2.2 |
1949-01-16 | -0.5 | -4.9 | -2.5 | 0.9 |
1949-01-17 | -0.7 | -4.0 | -3.2 | 0.1 |
1949-01-18 | -3.8 | -10.3 | -7.5 | 0.0 |
1949-01-19 | -6.9 | -10.4 | -8.8 | 0.2 |
1949-01-20 | -2.4 | -13.5 | -8.6 | 2.5 |
1949-01-21 | 1.6 | -2.6 | 0.0 | 3.6 |
1949-01-22 | 0.2 | -11.7 | -4.2 | 2.0 |
1949-01-23 | -11.4 | -15.5 | -13.4 | 0.0 |
1949-01-24 | -10.5 | -14.4 | -12.4 | 0.0 |
1949-01-25 | 1.7 | -11.5 | -1.8 | 4.4 |
1949-01-26 | -0.7 | -6.8 | -3.1 | 0.0 |
1949-01-27 | 1.1 | -9.1 | -3.7 | 0.0 |
1949-01-28 | 1.2 | -2.6 | -1.2 | 0.0 |
1949-01-29 | 1.4 | -2.6 | -0.1 | 0.0 |
1949-01-30 | -0.5 | -8.1 | -6.5 | 0.0 |
1949-01-31 | -0.7 | -7.9 | -2.4 | 2.1 |
df["1949-01-01"]
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) /usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance) 2896 try: -> 2897 return self._engine.get_loc(key) 2898 except KeyError: pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: '1949-01-01' During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) <ipython-input-83-daf5924a8e56> in <module>() ----> 1 df["1949-01-01"] /usr/local/lib/python3.7/site-packages/pandas/core/frame.py in __getitem__(self, key) 2993 if self.columns.nlevels > 1: 2994 return self._getitem_multilevel(key) -> 2995 indexer = self.columns.get_loc(key) 2996 if is_integer(indexer): 2997 indexer = [indexer] /usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance) 2897 return self._engine.get_loc(key) 2898 except KeyError: -> 2899 return self._engine.get_loc(self._maybe_cast_indexer(key)) 2900 indexer = self.get_indexer([key], method=method, tolerance=tolerance) 2901 if indexer.ndim > 1 or indexer.size > 1: pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: '1949-01-01'
df['TMPMN']
DATE_OBS 1949-01-01 -4.2 1949-01-02 -1.2 1949-01-03 -0.7 1949-01-04 2.3 1949-01-05 1.1 ... 2006-10-27 5.6 2006-10-28 8.2 2006-10-29 2.4 2006-10-30 -0.7 2006-10-31 -3.0 Name: TMPMN, Length: 21121, dtype: float64
df['mon'] = df.index.month
df['year'] = df.index.year
df['day'] = df.index.day
df_pivoted = df.pivot_table(values='TMPMN',
index='year',
columns='mon')
plt.scatter(df_pivoted[3], df_pivoted[4])
<matplotlib.collections.PathCollection at 0x114c4aeb8>
df_pivoted.corr()
mon | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
mon | ||||||||||||
1 | 1.000000 | 0.384755 | 0.257302 | 0.216484 | 0.047153 | 0.039691 | 0.206568 | -0.120758 | 0.134955 | 0.117936 | -0.142560 | -0.059667 |
2 | 0.384755 | 1.000000 | 0.379095 | 0.216300 | 0.017000 | 0.028284 | 0.252928 | -0.097432 | 0.033740 | 0.071301 | 0.059700 | -0.012276 |
3 | 0.257302 | 0.379095 | 1.000000 | 0.328143 | 0.071455 | 0.177538 | 0.091281 | 0.022202 | -0.081379 | -0.037189 | -0.031521 | -0.075481 |
4 | 0.216484 | 0.216300 | 0.328143 | 1.000000 | 0.041331 | 0.017182 | 0.159124 | -0.117359 | 0.028134 | 0.037973 | 0.077483 | 0.000211 |
5 | 0.047153 | 0.017000 | 0.071455 | 0.041331 | 1.000000 | -0.121644 | 0.028159 | 0.118944 | 0.038196 | 0.178622 | 0.175155 | -0.156485 |
6 | 0.039691 | 0.028284 | 0.177538 | 0.017182 | -0.121644 | 1.000000 | 0.306204 | 0.093280 | -0.060803 | 0.111169 | -0.370548 | 0.150160 |
7 | 0.206568 | 0.252928 | 0.091281 | 0.159124 | 0.028159 | 0.306204 | 1.000000 | 0.411425 | 0.131770 | 0.132230 | 0.000195 | 0.053797 |
8 | -0.120758 | -0.097432 | 0.022202 | -0.117359 | 0.118944 | 0.093280 | 0.411425 | 1.000000 | 0.222137 | 0.179547 | 0.123741 | 0.002483 |
9 | 0.134955 | 0.033740 | -0.081379 | 0.028134 | 0.038196 | -0.060803 | 0.131770 | 0.222137 | 1.000000 | 0.277824 | 0.077645 | 0.054884 |
10 | 0.117936 | 0.071301 | -0.037189 | 0.037973 | 0.178622 | 0.111169 | 0.132230 | 0.179547 | 0.277824 | 1.000000 | 0.146520 | -0.031469 |
11 | -0.142560 | 0.059700 | -0.031521 | 0.077483 | 0.175155 | -0.370548 | 0.000195 | 0.123741 | 0.077645 | 0.146520 | 1.000000 | -0.112312 |
12 | -0.059667 | -0.012276 | -0.075481 | 0.000211 | -0.156485 | 0.150160 | 0.053797 | 0.002483 | 0.054884 | -0.031469 | -0.112312 | 1.000000 |
corr = df_pivoted.corr()
import matplotlib.pyplot as plt
import numpy as np
plt.imshow(corr[np.abs(corr) > 0.3], vmin=-1, vmax=1,
cmap='seismic')
plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x114fc5e10>
months = ['jan', 'feb', 'mar', 'apr', 'may',
'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
import calendar
plt.figure(figsize=(7, 7))
plt.imshow(corr, vmin=-1, vmax=1,
cmap='seismic')
plt.xticks(range(12), months, rotation=90)
plt.yticks(range(12), months)
plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x119b5aac8>
df.groupby(['mon', 'year']).mean()['TMPMN'].unstack().T
mon | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
year | ||||||||||||
1949 | -3.670968 | -7.339286 | -2.780645 | 4.280000 | 15.225806 | 16.973333 | 17.425806 | 16.074194 | 11.506667 | 4.800000 | -0.423333 | -4.322581 |
1950 | -18.022581 | -6.764286 | -2.225806 | 9.043333 | 11.738710 | 15.123333 | 16.177419 | 14.080645 | 11.990000 | 4.745161 | -0.433333 | -5.503226 |
1951 | -12.138710 | -12.264286 | -3.996774 | 8.403333 | 9.738710 | 17.706667 | 18.590323 | 18.325806 | 11.990000 | 2.780645 | -4.810000 | -1.251613 |
1952 | -4.135484 | -7.096552 | -9.106452 | 5.166667 | 10.358065 | 17.340000 | 17.870968 | 16.848387 | 12.136667 | 3.925806 | -1.133333 | -5.883871 |
1953 | -10.403226 | -15.614286 | -2.606452 | 7.183333 | 11.645161 | 19.193333 | 19.025806 | 17.290323 | 10.046667 | 5.790323 | -3.156667 | -5.632258 |
1954 | -14.306452 | -14.000000 | -3.425806 | 3.030000 | 12.883871 | 18.963333 | 21.025806 | 18.354839 | 12.286667 | 5.738710 | -1.573333 | -4.974194 |
1955 | -6.312903 | -6.792857 | -4.664516 | 1.466667 | 10.506452 | 15.100000 | 17.906452 | 17.916129 | 13.856667 | 7.712903 | -3.023333 | -14.306452 |
1956 | -10.916129 | -18.503448 | -3.600000 | 3.940000 | 10.664516 | 20.570000 | 15.190323 | 14.625806 | 8.423333 | 4.670968 | -5.180000 | -4.254839 |
1957 | -6.038710 | -1.760714 | -6.319355 | 6.640000 | 14.435484 | 15.240000 | 18.554839 | 17.087097 | 12.313333 | 5.241935 | -0.893333 | -4.622581 |
1958 | -6.932258 | -7.710714 | -6.080645 | 4.063333 | 13.290323 | 14.890000 | 18.367742 | 15.696774 | 9.080000 | 6.038710 | -0.786667 | -7.641935 |
1959 | -4.335484 | -5.492857 | -1.425806 | 6.630000 | 11.490323 | 16.886667 | 20.538710 | 16.932258 | 8.253333 | 2.229032 | -5.110000 | -10.990323 |
1960 | -9.351613 | -7.651724 | -5.480645 | 5.046667 | 11.625806 | 18.486667 | 21.009677 | 16.190323 | 9.800000 | 2.338710 | -3.620000 | 0.167742 |
1961 | -6.174194 | -2.335714 | 0.245161 | 4.310000 | 12.058065 | 19.173333 | 19.374194 | 16.825806 | 9.686667 | 6.590323 | -1.550000 | -8.070968 |
1962 | -4.248387 | -6.057143 | -5.012903 | 7.590000 | 13.225806 | 13.506667 | 16.361290 | 14.832258 | 10.790000 | 6.451613 | 1.343333 | -7.351613 |
1963 | -15.929032 | -10.057143 | -9.429032 | 3.886667 | 17.022581 | 13.540000 | 19.132258 | 17.796774 | 13.216667 | 5.651613 | -0.216667 | -8.751613 |
1964 | -8.074194 | -9.975862 | -6.190323 | 4.206667 | 11.529032 | 18.983333 | 19.990323 | 16.006452 | 11.806667 | 6.893548 | -2.306667 | -2.858065 |
1965 | -9.529032 | -10.071429 | -3.303226 | 2.523333 | 9.738710 | 16.016667 | 16.661290 | 15.735484 | 12.923333 | 3.806452 | -5.786667 | -1.493548 |
1966 | -9.664516 | -8.857143 | 0.009677 | 8.716667 | 15.422581 | 16.540000 | 19.212903 | 16.645161 | 9.543333 | 6.087097 | -0.900000 | -10.525806 |
1967 | -13.922581 | -10.435714 | 0.338710 | 6.566667 | 16.945161 | 16.453333 | 17.706452 | 18.361290 | 11.353333 | 9.003226 | 0.420000 | -9.583871 |
1968 | -15.548387 | -8.265517 | -1.000000 | 6.020000 | 12.383871 | 18.330000 | 15.725806 | 17.712903 | 10.790000 | 2.954839 | -2.533333 | -5.322581 |
1969 | -16.170968 | -13.435714 | -6.912903 | 5.973333 | 11.125806 | 14.736667 | 17.803226 | 16.445161 | 10.220000 | 4.690323 | 1.786667 | -9.158065 |
1970 | -10.374194 | -8.325000 | -2.851613 | 5.833333 | 12.600000 | 15.820000 | 19.316129 | 16.258065 | 11.090000 | 5.393548 | -1.823333 | -5.887097 |
1971 | -3.538710 | -9.417857 | -4.161290 | 3.826667 | 12.774194 | 16.380000 | 17.467742 | 16.729032 | 10.780000 | 3.222581 | -0.630000 | -5.651613 |
1972 | -14.874194 | -7.403448 | -2.541935 | 5.880000 | 12.574194 | 18.983333 | 22.412903 | 20.632258 | 10.983333 | 5.167742 | -0.186667 | -0.906452 |
1973 | -10.248387 | -3.385714 | -1.016129 | 7.880000 | 13.254839 | 18.240000 | 17.977419 | 15.909677 | 7.633333 | 3.845161 | -2.060000 | -5.861290 |
1974 | -10.219355 | -1.460714 | -0.619355 | 3.403333 | 9.641935 | 16.446667 | 18.180645 | 15.874194 | 13.103333 | 8.680645 | 1.776667 | -2.335484 |
1975 | -3.670968 | -6.385714 | 1.238710 | 10.066667 | 15.638710 | 17.776667 | 18.500000 | 15.019355 | 13.663333 | 4.093548 | -3.296667 | -4.032258 |
1976 | -12.241935 | -11.455172 | -2.558065 | 5.723333 | 10.925806 | 13.713333 | 16.103226 | 14.500000 | 9.653333 | -0.948387 | -0.803333 | -3.690323 |
1977 | -11.254839 | -6.332143 | -0.851613 | 7.030000 | 14.229032 | 16.836667 | 18.764516 | 15.825806 | 9.506667 | 3.100000 | 1.726667 | -8.174194 |
1978 | -7.270968 | -9.500000 | 0.390323 | 4.613333 | 10.493548 | 14.313333 | 16.345161 | 15.774194 | 9.723333 | 3.341935 | 2.003333 | -14.509677 |
1979 | -9.954839 | -8.828571 | -0.883871 | 3.310000 | 17.106452 | 17.153333 | 16.674194 | 16.938710 | 11.730000 | 3.838710 | -0.913333 | -5.658065 |
1980 | -11.312903 | -7.151724 | -6.370968 | 5.846667 | 8.370968 | 17.870000 | 17.200000 | 14.709677 | 10.536667 | 5.190323 | -2.040000 | -4.248387 |
1981 | -5.393548 | -4.907143 | -3.135484 | 3.340000 | 14.019355 | 19.813333 | 21.512903 | 17.396774 | 10.816667 | 7.806452 | -0.583333 | -3.509677 |
1982 | -10.158065 | -8.792857 | -0.648387 | 5.336667 | 11.977419 | 13.856667 | 18.400000 | 16.645161 | 11.753333 | 4.064516 | 2.033333 | -1.135484 |
1983 | -3.967742 | -6.878571 | -1.403226 | 9.290000 | 15.612903 | 14.550000 | 17.938710 | 16.032258 | 12.413333 | 6.200000 | -1.466667 | -3.180645 |
1984 | -4.409677 | -10.268966 | -2.354839 | 7.466667 | 15.970968 | 15.590000 | 17.567742 | 15.125806 | 12.410000 | 6.800000 | -3.543333 | -9.590323 |
1985 | -10.012903 | -14.014286 | -3.067742 | 5.346667 | 12.974194 | 14.663333 | 16.438710 | 19.419355 | 10.123333 | 6.070968 | -3.333333 | -6.535484 |
1986 | -6.725806 | -13.539286 | 0.158065 | 6.680000 | 13.648387 | 18.633333 | 17.796774 | 16.516129 | 8.580000 | 4.174194 | -0.093333 | -7.454839 |
1987 | -17.506452 | -6.057143 | -5.312903 | 2.810000 | 12.832258 | 17.736667 | 16.764516 | 15.087097 | 9.046667 | 3.590323 | -3.646667 | -6.983871 |
1988 | -7.241935 | -6.113793 | -0.993548 | 5.346667 | 13.848387 | 19.530000 | 21.587097 | 16.474194 | 11.280000 | 4.870968 | -4.440000 | -6.935484 |
1989 | -2.112903 | -0.503571 | 1.990323 | 7.656667 | 13.396774 | 20.053333 | 19.161290 | 16.248387 | 12.176667 | 5.329032 | -2.633333 | -5.293548 |
1990 | -5.667742 | 0.382143 | 1.980645 | 8.120000 | 10.803226 | 14.506667 | 17.535484 | 15.954839 | 9.320000 | 5.358065 | 0.250000 | -3.393548 |
1991 | -4.875862 | -6.678571 | -1.219355 | 7.030000 | 13.387097 | 18.783333 | 18.080645 | 16.090323 | 10.973333 | 6.538710 | 0.970000 | -3.974194 |
1992 | -5.270968 | -4.313793 | 1.654839 | 5.140000 | 11.932258 | 16.693333 | 18.622581 | 18.041935 | 13.146667 | 2.154839 | -2.533333 | -4.396774 |
1993 | -4.416129 | -4.882143 | -1.932258 | 5.730000 | 14.490323 | 14.023333 | 17.506452 | 15.425806 | 6.870000 | 4.645161 | -8.003333 | -3.612903 |
1994 | -3.422581 | -11.300000 | -2.929032 | 7.226667 | 9.848387 | 14.546667 | 17.561290 | 15.870968 | 13.676667 | 4.958065 | -2.526667 | -7.948387 |
1995 | -5.874194 | -0.846429 | 0.587097 | 9.116667 | 14.470968 | 19.683333 | 17.548387 | 16.793548 | 12.823333 | 6.683871 | -2.816667 | -9.506452 |
1996 | -10.019355 | -9.689655 | -3.045161 | 6.403333 | 15.703226 | 16.526667 | 18.900000 | 17.274194 | 9.880000 | 6.051613 | 3.863333 | -7.019355 |
1997 | -7.732258 | -4.682143 | -0.932258 | 4.650000 | 11.093548 | 17.830000 | 18.729032 | 17.122581 | 8.516667 | 3.677419 | -0.843333 | -7.538710 |
1998 | -4.725806 | -7.642857 | -1.348387 | 3.900000 | 13.712903 | 19.976667 | 18.864516 | 15.487097 | 10.700000 | 5.658065 | -8.030000 | -5.938710 |
1999 | -4.577419 | -6.253571 | -0.835484 | 9.683333 | 8.674194 | 21.423333 | 21.719355 | 16.406452 | 11.770000 | 7.374194 | -4.933333 | -1.706452 |
2000 | -6.112903 | -2.703448 | -0.700000 | 11.110000 | 10.825806 | 16.236667 | 19.332258 | 16.754839 | 10.043333 | 7.180645 | -0.050000 | -2.625806 |
2001 | -4.312903 | -7.192857 | -2.125806 | 10.966667 | 11.251613 | 16.266667 | 22.967742 | 16.964516 | 12.193333 | 4.806452 | -0.526667 | -10.580645 |
2002 | -4.754839 | -0.425000 | 2.229032 | 7.183333 | 12.732258 | 17.310000 | 22.638710 | 17.041935 | 12.030000 | 2.545161 | -1.476667 | -12.561290 |
2003 | -7.351613 | -8.653571 | -2.729032 | 4.673333 | 15.535484 | 12.820000 | 20.641935 | 16.948387 | 11.333333 | 5.567742 | 1.146667 | -2.061290 |
2004 | -6.458065 | -7.006897 | 1.345161 | 4.556667 | 11.412903 | 15.283333 | 19.022581 | 18.383871 | 12.133333 | 5.935484 | -1.560000 | -2.935484 |
2005 | -3.000000 | -8.903571 | -6.029032 | 7.116667 | 14.832258 | 16.506667 | 19.309677 | 17.638710 | 13.123333 | 6.022581 | 1.370000 | -4.148387 |
2006 | -10.787097 | -13.307143 | -3.719355 | 6.020000 | 12.432258 | 18.203333 | 17.977419 | 17.535484 | 13.303333 | 7.003226 | NaN | NaN |
groupped = df.groupby(['mon', 'year']).mean()
groupped.loc[[(1, 1949), (2, 1958)]]
TMPMAX | TMPMIN | TMPMN | PRECIP | day | ||
---|---|---|---|---|---|---|
mon | year | |||||
1 | 1949 | -1.300000 | -6.493548 | -3.670968 | 0.854839 | 16.0 |
2 | 1958 | -3.907143 | -11.442857 | -7.710714 | 1.967857 | 14.5 |
groupped.reset_index('year')
year | TMPMAX | TMPMIN | TMPMN | PRECIP | day | |
---|---|---|---|---|---|---|
mon | ||||||
1 | 1949 | -1.300000 | -6.493548 | -3.670968 | 0.854839 | 16.0 |
1 | 1950 | -14.348387 | -21.616129 | -18.022581 | 0.261290 | 16.0 |
1 | 1951 | -8.709677 | -15.745161 | -12.138710 | 1.070968 | 16.0 |
1 | 1952 | -1.648387 | -6.722581 | -4.135484 | 1.606452 | 16.0 |
1 | 1953 | -7.300000 | -14.067742 | -10.403226 | 1.080645 | 16.0 |
... | ... | ... | ... | ... | ... | ... |
12 | 2001 | -7.825806 | -13.325806 | -10.580645 | 1.738710 | 16.0 |
12 | 2002 | -9.509677 | -15.980645 | -12.561290 | 1.187097 | 16.0 |
12 | 2003 | -0.112903 | -4.032258 | -2.061290 | 1.367742 | 16.0 |
12 | 2004 | -0.725806 | -5.309677 | -2.935484 | 1.835484 | 16.0 |
12 | 2005 | -2.274194 | -5.951613 | -4.148387 | 2.538710 | 16.0 |
694 rows × 6 columns