Skip to content

Instantly share code, notes, and snippets.

@misterhay
Created January 27, 2022 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misterhay/81ee4bdc42b7a3249a060806fe0aa926 to your computer and use it in GitHub Desktop.
Save misterhay/81ee4bdc42b7a3249a060806fe0aa926 to your computer and use it in GitHub Desktop.
Canadian temperature and precipitation 30 year averages for Canada from World Bank Climate Change Knowledge Portal
# download csv files from https://climateknowledgeportal.worldbank.org/download-data
import pandas as pd
import os
df = pd.DataFrame()
for root, dirs, files in os.walk('.'):
for name in files:
if name.endswith('.csv'):
df2 = pd.read_csv(os.path.join(root, name), skiprows=1)
df2['source'] = name
df = df.append(df2)
df['Type'] = df['source'].str[0]
df['Type'].replace('p', 'precipitation', inplace=True)
df['Type'].replace('t', 'temperature', inplace=True)
df['Years'] = df['source'].str.split('_').str[4]
df.drop(columns=['source'], inplace=True)
df.rename(columns={'Unnamed: 0':'Location'}, inplace=True)
df
Location Annual Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Type Years
Canada 503.79 32.33 26.88 29.52 27.73 36.94 54.34 62.54 59.18 52.66 45.7 40.76 35.2 precipitation 1901-1930
Northwest Territories / Territoires du Nord-Ouest 246.84 11.25 11.04 10.5 11.73 16.72 30.88 39.77 39.8 25.89 20.88 16.18 12.19 precipitation 1901-1930
Nova Scotia / Nouvelle-Écosse 1186.85 115.8 91.26 103.36 92.09 77.82 81.29 84.68 96.04 89.41 118.41 111.13 125.55 precipitation 1901-1930
Nunavut 222.87 8.05 7.26 8.62 11.45 13.98 19.45 33.81 38.0 30.36 25.17 16.42 10.31 precipitation 1901-1930
Ontario 681.84 40.74 33.69 38.84 41.06 54.83 75.88 85.1 76.22 79.0 62.96 50.44 43.09 precipitation 1901-1930
Prince Edward Island / Île-du-Prince-Édouard 961.22 80.65 68.3 75.49 70.74 67.12 70.92 72.5 85.37 81.97 100.77 91.77 95.61 precipitation 1901-1930
Quebec / Québec 772.8 48.72 38.82 45.77 44.15 56.47 76.74 91.47 90.13 87.98 75.38 64.62 52.55 precipitation 1901-1930
Alberta 433.66 24.62 19.31 22.74 22.03 41.97 71.44 65.9 56.34 40.91 21.74 23.96 22.7 precipitation 1901-1930
Saskatchewan 411.41 18.4 15.14 19.67 21.13 39.74 68.12 66.62 53.59 43.12 25.43 21.82 18.62 precipitation 1901-1930
British Columbia / Colombie-Britannique 858.13 86.35 71.47 64.92 44.59 52.46 66.33 62.55 58.08 65.04 88.7 99.92 97.71 precipitation 1901-1930
Yukon 264.66 11.94 13.57 12.14 8.57 17.43 40.42 53.58 41.38 22.5 14.57 15.68 12.87 precipitation 1901-1930
Manitoba 468.61 19.59 15.67 20.92 23.15 40.28 65.36 70.22 65.13 56.05 38.5 30.82 22.92 precipitation 1901-1930
New Brunswick / Nouveau-Brunswick 1031.86 91.95 71.81 90.1 76.44 74.31 84.86 93.37 93.64 86.3 96.67 79.49 92.91 precipitation 1901-1930
Newfoundland and Labrador / Terre-Neuve-et-Labrador 1008.22 83.24 68.99 79.66 67.88 64.98 88.6 101.62 93.84 88.91 89.28 92.64 88.6 precipitation 1901-1930
Canada 511.37 33.69 28.59 30.0 28.24 35.97 54.63 62.65 59.35 52.6 45.23 43.32 37.09 precipitation 1931-1960
Northwest Territories / Territoires du Nord-Ouest 253.3 11.96 10.91 11.61 11.57 16.57 28.62 41.08 40.17 26.28 21.33 18.51 14.7 precipitation 1931-1960
Nova Scotia / Nouvelle-Écosse 1283.8 133.46 108.9 103.03 95.12 93.0 86.11 80.44 97.66 104.35 113.36 141.74 126.61 precipitation 1931-1960
Nunavut 217.15 7.93 7.61 8.56 10.68 12.92 19.07 33.35 37.13 28.89 24.33 16.51 10.17 precipitation 1931-1960
Ontario 704.36 44.98 37.27 39.76 42.85 55.98 78.47 83.08 75.38 79.49 61.41 58.38 47.31 precipitation 1931-1960
Prince Edward Island / Île-du-Prince-Édouard 1035.49 95.38 83.01 73.77 73.11 78.88 74.65 68.91 83.73 93.34 95.68 117.49 97.53 precipitation 1931-1960
Quebec / Québec 784.44 49.12 40.57 44.44 45.06 55.04 80.18 94.42 89.9 92.6 72.77 66.71 53.64 precipitation 1931-1960
Alberta 454.09 26.22 23.4 25.57 23.95 42.25 68.85 68.29 56.11 38.93 25.46 28.55 26.51 precipitation 1931-1960
Saskatchewan 410.21 19.74 16.19 21.1 22.28 34.18 65.4 63.11 54.5 40.39 25.53 25.98 21.79 precipitation 1931-1960
British Columbia / Colombie-Britannique 897.45 91.76 77.68 70.28 47.0 50.6 69.94 65.78 60.1 62.05 94.2 102.11 105.96 precipitation 1931-1960
Yukon 264.69 12.91 12.81 12.87 7.99 17.42 38.49 51.75 43.41 21.22 14.52 17.83 13.47 precipitation 1931-1960
Manitoba 469.32 20.61 16.07 21.44 23.92 38.07 66.51 68.76 68.41 53.68 35.99 32.52 23.34 precipitation 1931-1960
New Brunswick / Nouveau-Brunswick 1084.38 100.58 84.57 84.97 80.39 79.45 95.84 91.9 85.82 91.79 92.27 101.69 95.11 precipitation 1931-1960
Newfoundland and Labrador / Terre-Neuve-et-Labrador 953.94 78.42 65.71 70.5 64.87 62.64 84.12 96.14 92.16 92.26 81.29 85.96 79.84 precipitation 1931-1960
Canada 530.4 34.67 27.67 30.17 29.51 38.85 56.12 66.08 62.73 55.32 47.67 43.29 38.33 precipitation 1961-1990
Northwest Territories / Territoires du Nord-Ouest 261.13 12.58 11.04 11.33 11.98 16.92 32.66 42.52 41.76 26.54 23.1 17.47 13.23 precipitation 1961-1990
Nova Scotia / Nouvelle-Écosse 1393.52 135.49 106.61 111.78 108.76 103.28 98.02 94.11 103.61 99.8 127.27 148.56 156.24 precipitation 1961-1990
Nunavut 223.82 8.11 7.16 8.76 11.58 14.02 19.41 33.93 38.15 30.51 25.26 16.52 10.4 precipitation 1961-1990
Ontario 730.24 43.2 34.1 40.36 43.7 57.62 82.09 88.39 84.5 84.12 66.21 57.28 48.67 precipitation 1961-1990
Prince Edward Island / Île-du-Prince-Édouard 1151.1 99.39 82.24 84.83 87.51 92.0 86.25 82.6 90.33 90.0 111.24 121.64 123.06 precipitation 1961-1990
Quebec / Québec 809.64 48.73 38.34 45.57 46.35 59.18 79.51 96.03 96.15 94.01 77.36 70.09 58.33 precipitation 1961-1990
Alberta 467.17 27.25 20.71 23.37 24.02 44.18 71.7 75.83 60.37 43.84 23.74 25.96 26.21 precipitation 1961-1990
Saskatchewan 423.06 19.8 15.44 20.14 23.24 39.34 64.05 70.15 55.21 44.7 26.79 22.19 22.0 precipitation 1961-1990
British Columbia / Colombie-Britannique 925.17 99.78 77.69 66.92 50.0 57.73 70.4 70.72 63.6 68.81 94.52 101.84 103.14 precipitation 1961-1990
Yukon 275.9 13.46 13.45 12.42 8.54 19.19 42.93 56.13 42.51 23.38 15.44 15.45 13.0 precipitation 1961-1990
Manitoba 484.14 20.35 15.58 21.3 25.45 41.5 65.86 72.88 69.4 57.83 39.66 30.72 23.61 precipitation 1961-1990
New Brunswick / Nouveau-Brunswick 1153.78 97.71 76.15 88.24 84.19 95.79 92.18 103.11 98.35 94.68 99.56 107.2 116.61 precipitation 1961-1990
Newfoundland and Labrador / Terre-Neuve-et-Labrador 1028.5 85.33 69.5 80.33 68.48 66.45 89.84 101.33 98.28 93.21 91.34 93.42 90.97 precipitation 1961-1990
Canada 532.87 33.83 26.33 30.47 29.96 39.23 58.25 67.2 62.37 55.91 49.96 42.68 36.68 precipitation 1991-2020
Northwest Territories / Territoires du Nord-Ouest 259.76 11.59 11.06 11.42 11.42 16.43 32.72 42.71 43.32 27.32 21.95 16.95 12.87 precipitation 1991-2020
Nova Scotia / Nouvelle-Écosse 1380.71 126.98 106.46 117.09 103.0 96.39 104.87 87.09 100.33 102.96 136.47 147.58 151.49 precipitation 1991-2020
Nunavut 218.46 7.59 6.88 8.67 10.81 13.36 19.76 33.13 37.68 29.86 23.87 16.08 10.77 precipitation 1991-2020
Ontario 749.6 44.47 34.84 39.11 46.42 62.27 82.48 92.89 81.13 85.82 74.22 56.91 49.03 precipitation 1991-2020
Prince Edward Island / Île-du-Prince-Édouard 1150.42 94.08 84.02 87.15 83.22 87.42 97.12 75.45 89.27 91.22 120.47 121.31 119.7 precipitation 1991-2020
Quebec / Québec 820.39 48.46 37.7 46.69 47.56 60.5 79.71 99.1 94.67 98.74 83.56 67.02 56.68 precipitation 1991-2020
Alberta 461.58 23.85 18.88 24.06 26.33 43.25 79.3 73.1 58.11 42.29 25.36 25.31 21.73 precipitation 1991-2020
Saskatchewan 431.34 19.69 14.29 19.35 24.81 38.8 74.23 73.68 53.8 41.38 30.65 21.79 18.88 precipitation 1991-2020
British Columbia / Colombie-Britannique 905.41 95.71 66.81 71.5 50.27 55.83 75.03 69.28 62.73 66.85 92.43 103.58 95.4 precipitation 1991-2020
Yukon 274.71 13.9 12.93 12.66 8.15 18.08 43.0 54.87 44.97 22.91 14.28 16.49 12.48 precipitation 1991-2020
Manitoba 503.87 20.08 15.54 20.16 24.17 43.83 71.37 78.66 72.6 59.44 44.02 30.61 23.4 precipitation 1991-2020
New Brunswick / Nouveau-Brunswick 1212.78 103.36 83.12 99.3 90.04 95.21 108.93 99.34 91.3 97.2 118.6 105.77 120.61 precipitation 1991-2020
Newfoundland and Labrador / Terre-Neuve-et-Labrador 1032.55 83.73 67.48 75.07 69.12 69.8 85.1 105.6 102.03 96.36 99.74 92.04 86.5 precipitation 1991-2020
Canada -5.58 -23.59 -22.22 -16.81 -7.59 1.26 8.13 12.06 10.44 4.97 -2.25 -11.84 -19.52 temperature 1901-1930
Northwest Territories / Territoires du Nord-Ouest -9.63 -29.7 -28.2 -23.96 -12.83 -1.38 7.21 11.32 9.13 2.79 -6.04 -18.38 -25.53 temperature 1901-1930
Nova Scotia / Nouvelle-Écosse 5.33 -6.48 -7.13 -2.16 3.07 8.46 13.38 17.39 16.84 13.24 8.24 2.56 -3.39 temperature 1901-1930
Nunavut -14.68 -32.39 -32.99 -29.84 -20.62 -9.02 0.88 6.37 4.5 -2.03 -11.34 -21.52 -28.17 temperature 1901-1930
Ontario -0.16 -19.22 -17.75 -10.1 -0.76 7.11 13.31 16.68 15.03 10.2 3.58 -5.15 -14.87 temperature 1901-1930
Prince Edward Island / Île-du-Prince-Édouard 4.83 -8.34 -8.74 -3.4 2.18 8.3 13.73 18.08 17.4 13.41 8.06 1.96 -4.68 temperature 1901-1930
Quebec / Québec -3.41 -21.21 -20.65 -14.02 -5.43 2.89 9.03 12.71 11.52 7.01 0.83 -6.93 -16.65 temperature 1901-1930
Alberta -0.04 -17.88 -14.5 -8.48 1.38 7.9 12.19 15.09 13.44 8.21 2.73 -6.85 -13.76 temperature 1901-1930
Saskatchewan -0.99 -21.24 -18.23 -10.93 0.27 7.82 13.08 16.34 14.62 8.75 2.37 -7.82 -16.87 temperature 1901-1930
British Columbia / Colombie-Britannique 0.55 -12.17 -9.67 -5.22 0.55 5.59 9.4 12.2 11.4 7.21 2.27 -5.3 -9.62 temperature 1901-1930
Yukon -7.36 -26.4 -22.14 -17.1 -7.84 1.36 7.95 10.52 8.3 2.62 -5.15 -17.39 -23.01 temperature 1901-1930
Manitoba -2.88 -24.05 -21.5 -13.77 -2.71 5.44 11.84 15.88 14.09 8.2 1.09 -9.4 -19.67 temperature 1901-1930
New Brunswick / Nouveau-Brunswick 3.33 -11.93 -11.19 -4.42 2.15 8.82 14.11 17.66 16.16 11.7 6.13 -0.87 -8.42 temperature 1901-1930
Newfoundland and Labrador / Terre-Neuve-et-Labrador -2.19 -17.08 -16.62 -11.04 -4.4 2.15 7.47 12.07 11.31 7.06 1.12 -5.25 -13.05 temperature 1901-1930
Canada -5.12 -22.69 -21.5 -16.13 -7.12 1.76 8.36 12.44 10.95 5.44 -1.93 -11.81 -19.16 temperature 1931-1960
Northwest Territories / Territoires du Nord-Ouest -9.2 -28.79 -27.93 -22.65 -12.03 -0.72 7.35 11.44 9.52 3.14 -5.89 -18.33 -25.51 temperature 1931-1960
Nova Scotia / Nouvelle-Écosse 5.91 -5.49 -5.91 -2.02 3.55 8.98 13.75 17.79 17.51 13.72 8.43 3.37 -2.81 temperature 1931-1960
Nunavut -14.26 -31.48 -32.66 -28.69 -20.09 -8.53 0.92 6.59 4.9 -1.63 -11.09 -21.68 -27.71 temperature 1931-1960
Ontario 0.38 -18.2 -16.4 -9.96 -0.49 7.4 13.71 17.26 15.96 10.43 4.24 -5.15 -14.28 temperature 1931-1960
Prince Edward Island / Île-du-Prince-Édouard 5.43 -7.17 -7.36 -3.27 2.71 8.77 14.1 18.47 18.08 13.95 8.22 2.84 -4.16 temperature 1931-1960
Quebec / Québec -2.84 -20.4 -19.24 -13.32 -4.81 3.09 9.43 13.16 12.08 7.37 1.23 -6.46 -16.26 temperature 1931-1960
Alberta 0.45 -17.18 -14.13 -8.14 1.67 8.89 12.56 15.68 14.0 9.15 3.03 -6.84 -13.33 temperature 1931-1960
Saskatchewan -0.4 -20.42 -17.48 -10.59 0.56 8.74 13.33 17.32 15.52 9.65 2.89 -8.16 -16.11 temperature 1931-1960
British Columbia / Colombie-Britannique 0.89 -11.32 -9.15 -4.96 0.96 6.24 9.71 12.27 11.51 7.85 2.36 -5.38 -9.34 temperature 1931-1960
Yukon -7.05 -25.25 -22.07 -16.51 -7.1 1.71 8.17 10.58 8.36 2.96 -5.07 -16.99 -23.44 temperature 1931-1960
Manitoba -2.42 -23.22 -20.73 -13.53 -2.79 6.0 11.99 16.75 15.06 8.77 1.65 -9.88 -19.08 temperature 1931-1960
New Brunswick / Nouveau-Brunswick 3.97 -10.6 -9.64 -4.34 2.66 9.29 14.45 18.05 16.98 12.31 6.37 0.01 -7.89 temperature 1931-1960
Newfoundland and Labrador / Terre-Neuve-et-Labrador -1.78 -16.05 -15.22 -10.51 -4.12 2.01 7.7 12.28 11.56 7.37 1.36 -5.08 -12.74 temperature 1931-1960
Canada -5.1 -22.74 -20.96 -15.91 -6.97 1.82 8.7 12.41 10.95 5.19 -2.06 -12.03 -19.56 temperature 1961-1990
Northwest Territories / Territoires du Nord-Ouest -9.1 -28.96 -27.22 -22.49 -11.64 -0.54 8.01 11.58 9.54 2.99 -5.98 -19.02 -25.51 temperature 1961-1990
Nova Scotia / Nouvelle-Écosse 5.83 -5.85 -6.08 -1.89 3.29 8.93 14.06 17.72 17.52 13.35 8.35 3.29 -2.77 temperature 1961-1990
Nunavut -14.42 -31.45 -31.98 -29.35 -20.5 -8.92 1.11 6.48 4.71 -1.99 -11.38 -21.83 -28.0 temperature 1961-1990
Ontario 0.39 -18.72 -16.38 -9.23 -0.02 7.97 13.64 17.17 15.66 10.19 4.01 -4.8 -14.84 temperature 1961-1990
Prince Edward Island / Île-du-Prince-Édouard 5.28 -7.64 -7.66 -3.16 2.35 8.69 14.37 18.34 18.0 13.43 8.09 2.68 -4.06 temperature 1961-1990
Quebec / Québec -2.86 -20.45 -19.35 -13.34 -4.73 3.34 9.51 13.15 11.98 7.09 1.09 -6.23 -16.39 temperature 1961-1990
Alberta 0.58 -16.86 -12.8 -7.18 2.16 8.88 13.26 15.44 14.23 8.82 3.2 -7.74 -14.41 temperature 1961-1990
Saskatchewan -0.2 -20.21 -16.28 -9.5 1.11 8.96 14.29 17.0 15.64 9.33 2.91 -8.35 -17.24 temperature 1961-1990
British Columbia / Colombie-Britannique 1.0 -10.98 -8.02 -4.27 1.05 5.88 9.81 12.36 11.89 7.69 2.43 -5.93 -9.97 temperature 1961-1990
Yukon -7.1 -25.74 -21.78 -16.07 -6.99 1.67 8.24 10.91 8.7 2.97 -5.48 -18.25 -23.45 temperature 1961-1990
Manitoba -2.35 -23.37 -20.15 -12.99 -2.22 6.36 12.68 16.47 14.91 8.41 1.54 -9.73 -20.07 temperature 1961-1990
New Brunswick / Nouveau-Brunswick 3.87 -11.11 -9.8 -4.06 2.46 9.24 14.8 17.97 16.83 11.85 6.19 -0.11 -7.88 temperature 1961-1990
Newfoundland and Labrador / Terre-Neuve-et-Labrador -1.6 -16.07 -15.43 -10.49 -3.91 2.63 8.29 12.67 11.82 7.23 1.28 -4.62 -12.59 temperature 1961-1990
Canada -4.23 -21.2 -20.04 -15.0 -6.42 2.26 9.38 13.02 11.6 6.03 -1.7 -10.97 -17.68 temperature 1991-2020
Northwest Territories / Territoires du Nord-Ouest -7.89 -26.43 -25.23 -20.9 -10.7 0.1 8.88 12.24 10.03 3.67 -5.6 -17.31 -23.47 temperature 1991-2020
Nova Scotia / Nouvelle-Écosse 6.49 -5.24 -5.28 -1.64 3.64 9.38 14.38 18.29 18.28 14.47 8.97 3.9 -1.31 temperature 1991-2020
Nunavut -13.37 -30.32 -31.13 -27.95 -19.56 -8.43 2.09 7.33 5.36 -1.12 -10.29 -20.18 -26.3 temperature 1991-2020
Ontario 1.07 -17.54 -15.56 -8.55 0.04 8.3 14.45 17.49 16.31 11.18 3.96 -4.37 -12.86 temperature 1991-2020
Prince Edward Island / Île-du-Prince-Édouard 5.92 -7.1 -6.95 -2.95 2.64 9.12 14.68 18.85 18.76 14.53 8.68 3.32 -2.55 temperature 1991-2020
Quebec / Québec -2.09 -19.91 -19.19 -12.98 -4.43 3.92 10.25 13.98 13.07 8.18 1.89 -5.59 -14.22 temperature 1991-2020
Alberta 1.24 -14.6 -11.83 -6.31 2.35 8.87 13.32 15.84 14.56 9.49 2.58 -6.76 -12.62 temperature 1991-2020
Saskatchewan 0.46 -17.87 -15.3 -8.46 1.18 8.68 14.32 17.3 16.02 10.22 2.29 -7.52 -15.33 temperature 1991-2020
British Columbia / Colombie-Britannique 1.7 -9.2 -7.38 -3.89 1.62 6.65 10.38 12.94 12.43 8.18 2.36 -5.11 -8.56 temperature 1991-2020
Yukon -5.88 -23.29 -19.75 -15.55 -5.53 2.86 9.24 11.52 9.2 3.47 -4.92 -16.82 -20.98 temperature 1991-2020
Manitoba -1.62 -21.28 -19.15 -11.86 -2.15 6.19 13.09 16.76 15.46 9.4 1.21 -9.06 -18.09 temperature 1991-2020
New Brunswick / Nouveau-Brunswick 4.54 -10.44 -9.22 -3.96 2.72 9.78 15.14 18.49 17.64 13.03 6.8 0.54 -6.06 temperature 1991-2020
Newfoundland and Labrador / Terre-Neuve-et-Labrador -1.02 -15.86 -15.63 -10.34 -3.57 3.08 8.76 13.22 12.9 8.27 2.28 -4.2 -11.13 temperature 1991-2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment