You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

726 lines
219 KiB

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Weather test\n",
"成功访问\n",
"成功访问\n"
]
}
],
"source": [
"# weather.py\n",
"import requests\n",
"from bs4 import BeautifulSoup\n",
"import csv\n",
"import json\n",
"\n",
"\n",
"def getHTMLtext(url):\n",
" \"\"\"请求获得网页内容\"\"\"\n",
" try:\n",
" r = requests.get(url, timeout=30)\n",
" r.raise_for_status()\n",
" r.encoding = r.apparent_encoding\n",
" print(\"成功访问\")\n",
" return r.text\n",
" except:\n",
" print(\"访问错误\")\n",
" return \" \"\n",
"\n",
"\n",
"def get_content(html):\n",
" \"\"\"处理得到有用信息保存数据文件\"\"\"\n",
" final = [] # 初始化一个列表保存数据\n",
" bs = BeautifulSoup(html, \"html.parser\") # 创建BeautifulSoup对象\n",
" body = bs.body\n",
" data = body.find('div', {'id': '7d'}) # 找到div标签且id = 7d\n",
" # 下面爬取当天的数据\n",
" data2 = body.find_all('div', {'class': 'left-div'})\n",
" text = data2[2].find('script').string\n",
" text = text[text.index('=') + 1:-2] # 移除改var data=将其变为json数据\n",
" jd = json.loads(text)\n",
" dayone = jd['od']['od2'] # 找到当天的数据\n",
" final_day = [] # 存放当天的数据\n",
" count = 0\n",
" for i in dayone:\n",
" temp = []\n",
" if count <= 23:\n",
" temp.append(i['od21']) # 添加时间\n",
" temp.append(i['od22']) # 添加当前时刻温度\n",
" temp.append(i['od24']) # 添加当前时刻风力方向\n",
" temp.append(i['od25']) # 添加当前时刻风级\n",
" temp.append(i['od26']) # 添加当前时刻降水量\n",
" temp.append(i['od27']) # 添加当前时刻相对湿度\n",
" temp.append(i['od28']) # 添加当前时刻控制质量\n",
" # print(temp)\n",
" final_day.append(temp)\n",
" count = count + 1\n",
" # 下面爬取7天的数据\n",
" ul = data.find('ul') # 找到所有的ul标签\n",
" li = ul.find_all('li') # 找到左右的li标签\n",
" i = 0 # 控制爬取的天数\n",
" for day in li: # 遍历找到的每一个li\n",
" if i < 7 and i > 0:\n",
" temp = [] # 临时存放每天的数据\n",
" date = day.find('h1').string # 得到日期\n",
" date = date[0:date.index('日')] # 取出日期号\n",
" temp.append(date)\n",
" inf = day.find_all('p') # 找出li下面的p标签,提取第一个p标签的值即天气\n",
" temp.append(inf[0].string)\n",
"\n",
" tem_low = inf[1].find('i').string # 找到最低气温\n",
"\n",
" if inf[1].find('span') is None: # 天气预报可能没有最高气温\n",
" tem_high = None\n",
" else:\n",
" tem_high = inf[1].find('span').string # 找到最高气温\n",
" temp.append(tem_low[:-1])\n",
" if tem_high[-1] == '℃':\n",
" temp.append(tem_high[:-1])\n",
" else:\n",
" temp.append(tem_high)\n",
"\n",
" wind = inf[2].find_all('span') # 找到风向\n",
" for j in wind:\n",
" temp.append(j['title'])\n",
"\n",
" wind_scale = inf[2].find('i').string # 找到风级\n",
" index1 = wind_scale.index('级')\n",
" temp.append(int(wind_scale[index1 - 1:index1]))\n",
" final.append(temp)\n",
" i = i + 1\n",
" return final_day, final\n",
"\n",
"\n",
"# print(final)\n",
"def get_content2(html):\n",
" \"\"\"处理得到有用信息保存数据文件\"\"\"\n",
" final = [] # 初始化一个列表保存数据\n",
" bs = BeautifulSoup(html, \"html.parser\") # 创建BeautifulSoup对象\n",
" body = bs.body\n",
" data = body.find('div', {'id': '15d'}) # 找到div标签且id = 15d\n",
" ul = data.find('ul') # 找到所有的ul标签\n",
" li = ul.find_all('li') # 找到左右的li标签\n",
" final = []\n",
" i = 0 # 控制爬取的天数\n",
" for day in li: # 遍历找到的每一个li\n",
" if i < 8:\n",
" temp = [] # 临时存放每天的数据\n",
" date = day.find('span', {'class': 'time'}).string # 得到日期\n",
" date = date[date.index('') + 1:-2] # 取出日期号\n",
" temp.append(date)\n",
" weather = day.find('span', {'class': 'wea'}).string # 找到天气\n",
" temp.append(weather)\n",
" tem = day.find('span', {'class': 'tem'}).text # 找到温度\n",
" temp.append(tem[tem.index('/') + 1:-1]) # 找到最低气温\n",
" temp.append(tem[:tem.index('/') - 1]) # 找到最高气温\n",
" wind = day.find('span', {'class': 'wind'}).string # 找到风向\n",
" if '转' in wind: # 如果有风向变化\n",
" temp.append(wind[:wind.index('转')])\n",
" temp.append(wind[wind.index('转') + 1:])\n",
" else: # 如果没有风向变化,前后风向一致\n",
" temp.append(wind)\n",
" temp.append(wind)\n",
" wind_scale = day.find('span', {'class': 'wind1'}).string # 找到风级\n",
" index1 = wind_scale.index('级')\n",
" temp.append(int(wind_scale[index1 - 1:index1]))\n",
"\n",
" final.append(temp)\n",
" return final\n",
"\n",
"\n",
"def write_to_csv(file_name, data, day=14):\n",
" \"\"\"保存为csv文件\"\"\"\n",
" with open(file_name, 'a', errors='ignore', newline='') as f:\n",
" if day == 14:\n",
" header = ['日期', '天气', '最低气温', '最高气温', '风向1', '风向2', '风级']\n",
" else:\n",
" header = ['小时', '温度', '风力方向', '风级', '降水量', '相对湿度', '空气质量']\n",
" f_csv = csv.writer(f)\n",
" f_csv.writerow(header)\n",
" f_csv.writerows(data)\n",
"\n",
"\n",
"def main():\n",
" \"\"\"主函数\"\"\"\n",
" print(\"Weather test\")\n",
" # 珠海\n",
" url1 = 'http://www.weather.com.cn/weather/101280701.shtml' # 7天天气中国天气网\n",
" url2 = 'http://www.weather.com.cn/weather15d/101280701.shtml' # 8-15天天气中国天气网\n",
"\n",
" html1 = getHTMLtext(url1)\n",
" data1, data1_7 = get_content(html1) # 获得1-7天和当天的数据\n",
"\n",
" html2 = getHTMLtext(url2)\n",
" data8_14 = get_content2(html2) # 获得8-14天数据\n",
" data14 = data1_7 + data8_14\n",
" # print(data)\n",
" write_to_csv('weather14.csv', data14, 14) # 保存为csv文件\n",
" write_to_csv('weather1.csv', data1, 1)\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 小时 温度 风力方向 风级 降水量 相对湿度 空气质量\n",
"0 20 22 东南风 4 0 77 NaN\n",
"1 19 22 东南风 4 0 71 35.0\n",
"2 18 22 东南风 3 0 73 36.0\n",
"3 17 23 东南风 3 0 73 38.0\n",
"4 16 24 东南风 4 0 71 38.0\n",
"5 15 24 东南风 4 0 69 38.0\n",
"6 14 24 东南风 4 0 69 38.0\n",
"7 13 25 东南风 3 0 67 36.0\n",
"8 12 26 东风 3 0 65 34.0\n",
"9 11 24 东南风 4 0 66 26.0\n",
"10 10 23 东风 3 0 73 24.0\n",
"11 9 23 东风 3 0 70 24.0\n",
"12 8 23 东风 3 0 69 25.0\n",
"13 7 23 东风 2 0 71 31.0\n",
"14 6 23 东北风 2 0 76 41.0\n",
"15 5 23 东风 3 0 83 44.0\n",
"16 4 23 东南风 2 0 85 49.0\n",
"17 3 22 东南风 2 0 87 49.0\n",
"18 2 22 东风 2 0 88 51.0\n",
"19 1 23 东北风 1 0 82 53.0\n",
"20 0 23 东南风 1 0 82 56.0\n",
"21 23 23 东南风 2 0 81 54.0\n",
"22 22 24 东风 2 0 75 52.0\n",
"23 21 25 东风 1 0 61 52.0\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEUCAYAAAAstV3AAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XucVHX9+PHXexdYWOR+URB3V1PE1ARZSHAT8EDiBe+V\npd8sL5iWpWalReVXRa209EtmYVr9BPtqppaWFiwsl8SvcssL3rkIIVdBBOW6798fnzMwzM7snNmd\nM2cu7+fjMY+ZOXMun5nPzHvO+VxFVTHGGFM6yqJOgDHGmNyywG+MMSXGAr8xxpQYC/zGGFNiLPAb\nY0yJscBvSpqIHBB1GuKJ0zHqdJjiZoHf5A0/6LVr5rWKhGVdWnm8zwLPZrD++SLSLcB6bVuQlj3+\nn9AngLebWW+siHwyIU0jR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LC1VdfzciRIxk5ciR33HHH3vXKy8u59957mTRpEj169ODpp5/m2muvZfDgwTzyyCMR\nvoNgQm3VIyLDgG64+UGX4Ca5vlpEqlR1UsK643HT2lFVVRVmsoxpmXffzWy5ablrroHFi7O7z4ED\n4e67m12loqKCr33ta9x+++3s3r2bE044gerqagAWLFiwd73Gxkb+9Kc/MXfuXN544w3OPvtsNmzY\nwIYNG/j3v//NU0/ld8FGaIFfRLoDk4DzgO8Ak1V1jYhMwU2Vt1/gV9XJwGRwHbjCSpcxLVZV5Yp3\nki03RaFPnz5MmTKFTp060bdvXzZs2LD3tfPPP58+ffoArgXSFVdcwcUXX8yll15KbW0tq1ev5rDD\nDuP666+PKvmBhRL4/cr
"text/plain": [
"<matplotlib.figure.Figure at 0x2c4d52cf748>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEUCAYAAAAstV3AAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXl4U1X6xz9vWwoURJAdyuo2jqgoqIgIrSuKqOBuXXBk\ncB1/bowLjDIq6riNyrgM6ohKUdTRUVtUZAQFx4VFREXEhaqIIKDsa9v398e5KSFNm6TNbdLk/TxP\nniT3nnvPm3uSb859z3veI6qKYRiGkT5kJNoAwzAMo24x4TcMw0gzTPgNwzDSDBN+wzCMNMOE3zAM\nI80w4TeMGBCRpom2IRhxNEm0HUb9woTf8A1PlLKr2dcwzPYCEXkmDnVniEh5cP0i0qyW5zwWeDOG\n8qeJSIsoyjWogS1l3p/Q7sA31ZQbKCK/D7FpgIjYbz+NyUq0AUZKswcwS0S2e++bAeXABkCAhiLS\nRVU3Bh2z3XsgIkcARcCSoP2/B1qq6noRaQdsBQKTUTaoaimAqpaLyAZV3eadS4ApIvKEqk4QkWlA\nB2Bb0LmbA8+p6o3eMScCNweVyQR6iMgs731D4G1VvckT0kygVHdMjjkZ6AzcH2RDA69MeV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bNm0iJycn5uO2bdtGdnZ25IJxorbX3Xr8NWTjxo08+uindOmiHHjgDDZt2sQr\nr3yGqjJv3jzWrl2baBMNI23Yf//9AXj77bfp2rUreXl55OXl0b59e7788ssqjxs5ciSvvfYaAMuW\nLWPgwIF8//333HXXXfTs2bPiPHl5efTr1y/sOb766itOPPHEivelpVWtt5M8WI+/hhx00ChuueUP\nqF4M9ADm8d5719O48S6
"text/plain": [
"<matplotlib.figure.Figure at 0x2c4d53664e0>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'numpy.float64'>\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEUCAYAAADDdzb+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmYFNW9//H3h01RQlxAlLhGUXPVC8poCBAdccWLGpW4\nRDFGvShqEqLeRI1GTNxjjCauGMS4Rq4KNxE1cQNRIlc0qLk/94iCiYiCjBv79/dH1cBMT093z0D3\nLPV5Pc88U111Tp1Tc3q+VXXqVJUiAjMzy5YOLV0BMzOrPAd/M7MMcvA3M8sgB38zswxy8DczyyAH\nf7M2Ton1W7oe1rY4+FtZpYGpS4Fl6xTJ/5+SvlkkTRdJL0jaYg3q2UXSTpJGSerY3PXkWe9wSRuW\nkK5zM9a9QlI3YFvgzQLpDpT0bzl12kuS//8zrFNLV8Dave2ApyUtSz93B1YCnwIC1pG0VUR81kj+\n7sDRwLQCZZyclnOZpNxlnYD7IuK+2hmSpgKd02WdgE2Aj4DZwAfAvwEv10n/aFqPL3LW3RWoiYj9\n0nQdgI7A8lh9A82hwJbA1WkapWUvj4iVddb1jKSzI+IpSXcBD0TE/QW2GeCLiPhU0hJgSb4EaZ1+\nBYyoM3tQuq37SqqJiF/WSf9C+jdZWqDcLSKiV5G6WSvn4G9lFRFvAKsChaQxwMcRcU2+9JLmkASe\nZTnzX00nuwBdImLzdP6mw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M7MMcvA3M8sg\nB38zswxynz9tq5/OzGxt8JG/mVkGOfibmWWQg7+ZWQa5z9/M2qSmXqtrzrW99nw90Ef+ZmYZ5OBv\nZpZB7vZppvZ8Omhm7V9
"text/plain": [
"<matplotlib.figure.Figure at 0x2c4d5377f28>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1.5, 0, 0, 0, 0, 0, 3.076923076923077, 2.4444444444444446]\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAREAAAEXCAYAAACKzXCTAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsnXlcW9eZ939HC5sESAgJJFaDd+MV7wtxtmkTp9n6JmnT\ncd1OOl3StH2bpEna5O20naZJ2k7aaZtOp0s6TSbTSdpO3LRN02bq2LGNMTbY2GAMxhgMAiQBQguS\nkK7u8/6hxYDRei8gHH0/n/uxke499wju+ek5z/Oc5zAiQpo0adIki2S+O5AmTZqFTVpE0qRJI4i0\niKRJk0YQaRFJkyaNINIikiZNGkGkRSRNmjSCSIvILMIYy5zvPqRJM9uwhZonwhj7FoB8AByAWB9C\nCiATgIWInozQ3t0AdAl0wUtEL8bo4wkAbxLRPzHGGIBcAG4AfiLi47kJY0wCYGkC/ZqJznjvlyZN\noixkEWkFUA7Ah6kikg+AARib9JoUQBYCg2lthPbeBbArgS4ME5E2Sv9WAzgD4DEi+g5jrBCAJUab\nvyKij01rJxeAPYF+zUQ+EQltI02aGVmw0xkiqiGiPCLSEFFh6ABwFEDr5NeISE1E2ZEEJIgXwH4i\nYrEOAL8A4IrRxUcBXALwr4wxGQArgEUAqoPv3wNAGzzeH3zt4Azt+IL/fn2GfjwH4P1R+vn/gtdO\nxOhrmjRJI5vvDqQQfkSZFjHGcohosnB4opxbDeB+AB8mIi9j7LMAtgL4FAB58LRhIhoOnr8o+NrB\nGZrjItzjfgCPAyhjjPVOe3tgmuUxYxtp0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aj3efz/XZkZORVAKfT\nfpXUIi0iKQxjrEShUNy
"text/plain": [
"<matplotlib.figure.Figure at 0x2c4d567ceb8>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAegAAAGICAYAAACKpHNWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmYXFWd//H3N52wRHaIIIwQF0BQVjOKyhIYQESRQcWt\nFVwwwzK4/EYRCDIOAjKMoqOSaAMjChmUcRRQEUZUNgUlURBRHBUTZDU4LGpYw/f3x7lFV5rqpLqT\nrrrd9X49Tz/V99a9VacOTT51zj3nnshMJElSvUzqdgEkSdLTGdCSJNWQAS1JUg0Z0JIk1ZABLUlS\nDRnQkjouItbq8vtvGBGTu1kGaUUMaElExLojOHadlXyvfYHLVnBMf0R8eYSv+9yIWK9pe/uI2HiY\nwy8Hnj/k/I9ExLEreI8XNL3XXss57m0R8cUW+6dHxPsi4tDlvY8E4DdISQBzI+Ie4BjgWmBz4Mmm\n59fLzLUiIoBLI+LszDw3Iq4ANgUeaz4WuCAzjwOIiNcAJzYd0we8KCKurbZXB76bmcc3vcbj1Q8R\nsRvwLeD3Tc9vC2yYmX9u2vdWYEfgDdX2ycB1wMdbfN5Hqx8i4mTg+mr7iWHqh4jYH/i3iHgRkMBA\nRGyfmUtaHP4I8FDTuVcC61T7fgfc2PTcTyn/Fj/G8J6dmcN92dAEZUBLAjgEGAC2pgTFzpl5T+PJ\niLgVIDOzCtxLImJhdexrM/O3Tce+Gdim6bXXAa7NzP8XERsAUzLz3oiYVL3P/KZzp1THrw70VS37\nScAPMvPvm45rvDcR0VcdczpwftWKfkZVhjdUr5mZ+UT1BWM1SsC+OiLOB2YAFwMvAJ5sHJOZjza9\n3yTgo8DxWe7u9PuI+DbwaWBW03FTgb8FtgI2iYjdgZ8BW2XmpsPU/ePA6zJzYUS8HPgIsH/1PlRd\n8QuHOVcTmAEt9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",
"output_type": "stream",
"text": [
"相关系数为:-0.6557721797643076\n"
]
}
],
"source": [
"# data1_analysis.py\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"import math\n",
"\n",
"\n",
"def tem_curve(data):\n",
" \"\"\"温度曲线绘制\"\"\"\n",
" hour = list(data['小时'])\n",
" tem = list(data['温度'])\n",
" for i in range(0, 24):\n",
" if math.isnan(tem[i]) == True:\n",
" tem[i] = tem[i - 1]\n",
" tem_ave = sum(tem) / 24 # 求平均温度\n",
" tem_max = max(tem)\n",
" tem_max_hour = hour[tem.index(tem_max)] # 求最高温度\n",
" tem_min = min(tem)\n",
" tem_min_hour = hour[tem.index(tem_min)] # 求最低温度\n",
" x = []\n",
" y = []\n",
" for i in range(0, 24):\n",
" x.append(i)\n",
" y.append(tem[hour.index(i)])\n",
" plt.figure(1)\n",
" plt.plot(x, y, color='red', label='温度') # 画出温度曲线\n",
" plt.scatter(x, y, color='red') # 点出每个时刻的温度点\n",
" plt.plot([0, 24], [tem_ave, tem_ave], c='blue', linestyle='--', label='平均温度') # 画出平均温度虚线\n",
" plt.text(tem_max_hour + 0.15, tem_max + 0.15, str(tem_max), ha='center', va='bottom', fontsize=10.5) # 标出最高温度\n",
" plt.text(tem_min_hour + 0.15, tem_min + 0.15, str(tem_min), ha='center', va='bottom', fontsize=10.5) # 标出最低温度\n",
" plt.xticks(x)\n",
" plt.legend()\n",
" plt.title('一天温度变化曲线图')\n",
" plt.xlabel('时间/h')\n",
" plt.ylabel('摄氏度/℃')\n",
" plt.show()\n",
"\n",
"\n",
"def hum_curve(data):\n",
" \"\"\"相对湿度曲线绘制\"\"\"\n",
" hour = list(data['小时'])\n",
" hum = list(data['相对湿度'])\n",
" for i in range(0, 24):\n",
" if math.isnan(hum[i]) == True:\n",
" hum[i] = hum[i - 1]\n",
" hum_ave = sum(hum) / 24 # 求平均相对湿度\n",
" hum_max = max(hum)\n",
" hum_max_hour = hour[hum.index(hum_max)] # 求最高相对湿度\n",
" hum_min = min(hum)\n",
" hum_min_hour = hour[hum.index(hum_min)] # 求最低相对湿度\n",
" x = []\n",
" y = []\n",
" for i in range(0, 24):\n",
" x.append(i)\n",
" y.append(hum[hour.index(i)])\n",
" plt.figure(2)\n",
" plt.plot(x, y, color='blue', label='相对湿度') # 画出相对湿度曲线\n",
" plt.scatter(x, y, color='blue') # 点出每个时刻的相对湿度\n",
" plt.plot([0, 24], [hum_ave, hum_ave], c='red', linestyle='--', label='平均相对湿度') # 画出平均相对湿度虚线\n",
" plt.text(hum_max_hour + 0.15, hum_max + 0.15, str(hum_max), ha='center', va='bottom', fontsize=10.5) # 标出最高相对湿度\n",
" plt.text(hum_min_hour + 0.15, hum_min + 0.15, str(hum_min), ha='center', va='bottom', fontsize=10.5) # 标出最低相对湿度\n",
" plt.xticks(x)\n",
" plt.legend()\n",
" plt.title('一天相对湿度变化曲线图')\n",
" plt.xlabel('时间/h')\n",
" plt.ylabel('百分比/%')\n",
" plt.show()\n",
"\n",
"\n",
"def air_curve(data):\n",
" \"\"\"空气质量曲线绘制\"\"\"\n",
" hour = list(data['小时'])\n",
" air = list(data['空气质量'])\n",
" print(type(air[0]))\n",
" for i in range(0, 24):\n",
" if math.isnan(air[i]) == True:\n",
" air[i] = air[i - 1]\n",
" air_ave = sum(air) / 24 # 求平均空气质量\n",
" air_max = max(air)\n",
" air_max_hour = hour[air.index(air_max)] # 求最高空气质量\n",
" air_min = min(air)\n",
" air_min_hour = hour[air.index(air_min)] # 求最低空气质量\n",
" x = []\n",
" y = []\n",
" for i in range(0, 24):\n",
" x.append(i)\n",
" y.append(air[hour.index(i)])\n",
" plt.figure(3)\n",
"\n",
" for i in range(0, 24):\n",
" if y[i] <= 50:\n",
" plt.bar(x[i], y[i], color='lightgreen', width=0.7) # 1等级\n",
" elif y[i] <= 100:\n",
" plt.bar(x[i], y[i], color='wheat', width=0.7) # 2等级\n",
" elif y[i] <= 150:\n",
" plt.bar(x[i], y[i], color='orange', width=0.7) # 3等级\n",
" elif y[i] <= 200:\n",
" plt.bar(x[i], y[i], color='orangered', width=0.7) # 4等级\n",
" elif y[i] <= 300:\n",
" plt.bar(x[i], y[i], color='darkviolet', width=0.7) # 5等级\n",
" elif y[i] > 300:\n",
" plt.bar(x[i], y[i], color='maroon', width=0.7) # 6等级\n",
" plt.plot([0, 24], [air_ave, air_ave], c='black', linestyle='--') # 画出平均空气质量虚线\n",
" plt.text(air_max_hour + 0.15, air_max + 0.15, str(air_max), ha='center', va='bottom', fontsize=10.5) # 标出最高空气质量\n",
" plt.text(air_min_hour + 0.15, air_min + 0.15, str(air_min), ha='center', va='bottom', fontsize=10.5) # 标出最低空气质量\n",
" plt.xticks(x)\n",
" plt.title('一天空气质量变化曲线图')\n",
" plt.xlabel('时间/h')\n",
" plt.ylabel('空气质量指数AQI')\n",
" plt.show()\n",
"\n",
"\n",
"def wind_radar(data):\n",
" \"\"\"风向雷达图\"\"\"\n",
" wind = list(data['风力方向'])\n",
" wind_speed = list(data['风级'])\n",
" for i in range(0, 24):\n",
" if wind[i] == \"北风\":\n",
" wind[i] = 90\n",
" elif wind[i] == \"南风\":\n",
" wind[i] = 270\n",
" elif wind[i] == \"西风\":\n",
" wind[i] = 180\n",
" elif wind[i] == \"东风\":\n",
" wind[i] = 360\n",
" elif wind[i] == \"东北风\":\n",
" wind[i] = 45\n",
" elif wind[i] == \"西北风\":\n",
" wind[i] = 135\n",
" elif wind[i] == \"西南风\":\n",
" wind[i] = 225\n",
" elif wind[i] == \"东南风\":\n",
" wind[i] = 315\n",
" degs = np.arange(45, 361, 45)\n",
" temp = []\n",
" for deg in degs:\n",
" speed = []\n",
" # 获取 wind_deg 在指定范围的风速平均值数据\n",
" for i in range(0, 24):\n",
" if wind[i] == deg:\n",
" speed.append(wind_speed[i])\n",
" if len(speed) == 0:\n",
" temp.append(0)\n",
" else:\n",
" temp.append(sum(speed) / len(speed))\n",
" print(temp)\n",
" N = 8\n",
" theta = np.arange(0. + np.pi / 8, 2 * np.pi + np.pi / 8, 2 * np.pi / 8)\n",
" # 数据极径\n",
" radii = np.array(temp)\n",
" # 绘制极区图坐标系\n",
" plt.axes(polar=True)\n",
" # 定义每个扇区的RGB值R,G,Bx越大对应的颜色越接近蓝色\n",
" colors = [(1 - x / max(temp), 1 - x / max(temp), 0.6) for x in radii]\n",
" plt.bar(theta, radii, width=(2 * np.pi / N), bottom=0.0, color=colors)\n",
" plt.title('一天风级图', x=0.2, fontsize=20)\n",
" plt.show()\n",
"\n",
"\n",
"def calc_corr(a, b):\n",
" \"\"\"计算相关系数\"\"\"\n",
" a_avg = sum(a) / len(a)\n",
" b_avg = sum(b) / len(b)\n",
" cov_ab = sum([(x - a_avg) * (y - b_avg) for x, y in zip(a, b)])\n",
" sq = math.sqrt(sum([(x - a_avg) ** 2 for x in a]) * sum([(x - b_avg) ** 2 for x in b]))\n",
" corr_factor = cov_ab / sq\n",
" return corr_factor\n",
"\n",
"\n",
"def corr_tem_hum(data):\n",
" \"\"\"温湿度相关性分析\"\"\"\n",
" tem = data['温度']\n",
" hum = data['相对湿度']\n",
" plt.scatter(tem, hum, color='blue')\n",
" plt.title(\"温湿度相关性分析图\")\n",
" plt.xlabel(\"温度/℃\")\n",
" plt.ylabel(\"相对湿度/%\")\n",
" plt.text(20, 40, \"相关系数为:\" + str(calc_corr(tem, hum)), fontdict={'size': '10', 'color': 'red'})\n",
" plt.show()\n",
" print(\"相关系数为:\" + str(calc_corr(tem, hum)))\n",
"\n",
"\n",
"def main():\n",
" plt.rcParams['font.sans-serif'] = ['SimHei'] # 解决中文显示问题\n",
" plt.rcParams['axes.unicode_minus'] = False # 解决负号显示问题\n",
" data1 = pd.read_csv('weather1.csv', encoding='gb2312')\n",
" print(data1)\n",
" tem_curve(data1)\n",
" hum_curve(data1)\n",
" air_curve(data1)\n",
" wind_radar(data1)\n",
" corr_tem_hum(data1)\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 日期 天气 最低气温 最高气温 风向1 风向2 风级\n",
"0 16 多云 19 22 东风 东风 4\n",
"1 17 阴 19 22 无持续风向 无持续风向 3\n",
"2 18 多云 18 23 无持续风向 东北风 3\n",
"3 19 多云转阵雨 19 25 无持续风向 无持续风向 3\n",
"4 20 阵雨转多云 20 25 无持续风向 无持续风向 3\n",
"5 21 多云 22 28 无持续风向 无持续风向 3\n",
"6 22 多云 23 30 无持续风向 东南风 3\n",
"7 23 雨 24 27 南风 南风 3\n",
"8 24 雨 25 28 南风 南风 3\n",
"9 25 雨转阴 24 27 南风 南风 4\n",
"10 26 阴 25 28 南风 南风 3\n",
"11 27 阴转晴 24 28 南风 南风 3\n",
"12 28 晴 24 28 东南风 东南风 3\n",
"13 29 多云转晴 25 28 东南风 东南风 3\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAETCAYAAAAxsG14AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd4VNXWwOHfogQIvQsGgh3x+omABUUFyxV7AUEEFFBR\nsaF4bWBDBJFqA42oIEEEG4qIV0EREUQRc62AqICoVCnSIVnfH/sEJsmknzMzyaz3eeZJ5pwz+6yZ\nZNbs2XufvUVVMcYYEz/KRDsAY4wxkWWJ3xhj4owlfmOMiTOW+I0xJs5Y4jfGmDhjid+YOCJO5WjH\nYaLLEr/JQkReFZFOBTx2pIjc4+O5RUQS8thXIZ/H3yIiLfLYX70IMR0qIm0LeGyhy8/2+I4iUrMA\nx5UvQtnpIlIFOAxYnsdx7UWkWbaYzhARyxWlSLloB2Bizj5gb7gdXlJOV9V0b9NWYHfI/rJAGVXd\nG7KtK3C2qvYMU15P4AxV7eFtOhyYJyKZj68GZADbAAEqiEiyqm4XkWSgixdvpq7ABSIyO2RbeSBF\nVTcCY0VkDXA3MA9o7JWfqYaqVskWZhegsoj8AhwE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cBS/wmxnz00UesW7eOjIwMDj7YTfkjIqXyzWuCtXr1aqpWrUqTJk3IPstq\nSaaqbNy4kdWrV3PIIYcUqQxr4zcx5c477+SJJ55g5MiRbN++ff/2rVu3RjEqUxLt2rWL2rVrl6qk\nD64iVLt27WJVhizxm5gwceJEHnzwQQA2bdpEx44dmTdvHgDLly+nZs2a0QzPlFClLelnKu7zCizx\ni0gtETknZCk6Y3LVuXN
"text/plain": [
"<matplotlib.figure.Figure at 0x2c4d67db8d0>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[3.0, 0, 0, 0, 0, 3.2, 3.0, 4.0]\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAARQAAAEYCAYAAACdsgkCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsfXl4W9Wd9nssy6sk27K1eIsdx/ES23FiOyF2yAbMQIBp\nKaFsLdDl+xhmSmm/FoYCpZ3plK9laKHLkE477TCUTlc6hY+WZYDE8ZLdseN4ix3vi6zFWqx9u+f7\n40pCkiVb91pOHND7PPdJfO855557de97f+e3EkopEkgggQTigaQrPYEEEkjgw4MEoSSQQAJxQ4JQ\nEkgggbghQSgJJJBA3JAglAQSSCBuSBBKAgkkEDesmlAIISmEkE8TQprjMaEEYgchJPVKzyGBBIJB\nVuuHQghJB2AD8FNK6UOrHIsAeBvABUrpo6ua2CpBCPm/ALIAeACsdJMEAFIBaCmlT0UZ73YAcg5T\ncFFK/2OFOZ4B8Cal9Ju+eycGYAfgpZQysZyEEJIEoILDvCJhONbzJfDhRnIcxnCF/csblFJKCNkG\nwL3aseKAjwHYAHYuwYSSBYAAMAbtEwBIAzAMICKhAPgygD0czq8DEJVQCCF1AJoA/N63KxeANuh4\npG4vU0o/E7YvE8Agh3lFQhaAxVWOkcCHADETCiFECEAIwBH2NWLC/vW393+1BZRSc9ixUrBf00jE\n4QGQRgipCp8C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tj231A7DLIQrgP+IwFvG9CEev2A1hdSZ/\nwQr6mmX6XwegNOjvVwB8kudYfw/WOhNRDxXU7hM+8hL7yHocPutOWLsqH9m9FLRPgrAlD1iT9F98\nhPR9375fgHXB/3pQu7d
"text/plain": [
"<matplotlib.figure.Figure at 0x2c4d6886f60>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'多云': 4, '阴': 2, '多云转阵雨': 1, '阵雨转多云': 1, '雨': 2, '雨转阴': 1, '阴转晴': 1, '晴': 1, '多云转晴': 1}\n"
]
},
{
"ename": "TypeError",
"evalue": "float() argument must be a string or a number, not 'dict_values'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-3-e3afdcfcaeea>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 130\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 131\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0m__name__\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m'__main__'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 132\u001b[1;33m \u001b[0mmain\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 133\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m<ipython-input-3-e3afdcfcaeea>\u001b[0m in \u001b[0;36mmain\u001b[1;34m()\u001b[0m\n\u001b[0;32m 126\u001b[0m \u001b[0mtem_curve\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdata14\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 127\u001b[0m \u001b[0mwind_radar\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdata14\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 128\u001b[1;33m \u001b[0mweather_pie\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdata14\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 129\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 130\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m<ipython-input-3-e3afdcfcaeea>\u001b[0m in \u001b[0;36mweather_pie\u001b[1;34m(data)\u001b[0m\n\u001b[0;32m 114\u001b[0m \u001b[0mexplode\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;36m0.01\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdic_wea\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mkeys\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 115\u001b[0m \u001b[0mcolor\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;34m'lightskyblue'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'silver'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'yellow'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'salmon'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'grey'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'lime'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'gold'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'red'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'green'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'pink'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 116\u001b[1;33m \u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpie\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdic_wea\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexplode\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mexplode\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlabels\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdic_wea\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mkeys\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mautopct\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'%1.1f%%'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcolors\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mcolor\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 117\u001b[0m \u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtitle\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'未来14天气候分布饼图'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 118\u001b[0m \u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshow\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\Users\\ymwy\\Anaconda3\\lib\\site-packages\\matplotlib\\pyplot.py\u001b[0m in \u001b[0;36mpie\u001b[1;34m(x, explode, labels, colors, autopct, pctdistance, shadow, labeldistance, startangle, radius, counterclock, wedgeprops, textprops, center, frame, hold, data)\u001b[0m\n\u001b[0;32m 3294\u001b[0m \u001b[0mradius\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mradius\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcounterclock\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mcounterclock\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3295\u001b[0m \u001b[0mwedgeprops\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mwedgeprops\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtextprops\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mtextprops\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcenter\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mcenter\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3296\u001b[1;33m frame=frame, data=data)\n\u001b[0m\u001b[0;32m 3297\u001b[0m \u001b[1;32mfinally\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3298\u001b[0m \u001b[0max\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_hold\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mwashold\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\Users\\ymwy\\Anaconda3\\lib\\site-packages\\matplotlib\\__init__.py\u001b[0m in \u001b[0;36minner\u001b[1;34m(ax, *args, **kwargs)\u001b[0m\n\u001b[0;32m 1895\u001b[0m warnings.warn(msg % (label_namer, func.__name__),\n\u001b[0;32m 1896\u001b[0m RuntimeWarning, stacklevel=2)\n\u001b[1;32m-> 1897\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0max\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1898\u001b[0m \u001b[0mpre_doc\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minner\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__doc__\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1899\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mpre_doc\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\Users\\ymwy\\Anaconda3\\lib\\site-packages\\matplotlib\\axes\\_axes.py\u001b[0m in \u001b[0;36mpie\u001b[1;34m(self, x, explode, labels, colors, autopct, pctdistance, shadow, labeldistance, startangle, radius, counterclock, wedgeprops, textprops, center, frame)\u001b[0m\n\u001b[0;32m 2570\u001b[0m \"\"\"\n\u001b[0;32m 2571\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2572\u001b[1;33m \u001b[0mx\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0masarray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mastype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfloat32\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2573\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2574\u001b[0m \u001b[0msx\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfloat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mTypeError\u001b[0m: float() argument must be a string or a number, not 'dict_values'"
]
}
],
"source": [
"# data14_analysis.py\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"import math\n",
"\n",
"\n",
"def tem_curve(data):\n",
" \"\"\"温度曲线绘制\"\"\"\n",
" date = list(data['日期'])\n",
" tem_low = list(data['最低气温'])\n",
" tem_high = list(data['最高气温'])\n",
" for i in range(0, 14):\n",
" if math.isnan(tem_low[i]) == True:\n",
" tem_low[i] = tem_low[i - 1]\n",
" if math.isnan(tem_high[i]) == True:\n",
" tem_high[i] = tem_high[i - 1]\n",
"\n",
" tem_high_ave = sum(tem_high) / 14 # 求平均高温\n",
" tem_low_ave = sum(tem_low) / 14 # 求平均低温\n",
"\n",
" tem_max = max(tem_high)\n",
" tem_max_date = tem_high.index(tem_max) # 求最高温度\n",
" tem_min = min(tem_low)\n",
" tem_min_date = tem_low.index(tem_min) # 求最低温度\n",
"\n",
" x = range(1, 15)\n",
" plt.figure(1)\n",
" plt.plot(x, tem_high, color='red', label='高温') # 画出高温度曲线\n",
" plt.scatter(x, tem_high, color='red') # 点出每个时刻的温度点\n",
" plt.plot(x, tem_low, color='blue', label='低温') # 画出低温度曲线\n",
" plt.scatter(x, tem_low, color='blue') # 点出每个时刻的温度点\n",
"\n",
" plt.plot([1, 15], [tem_high_ave, tem_high_ave], c='black', linestyle='--') # 画出平均温度虚线\n",
" plt.plot([1, 15], [tem_low_ave, tem_low_ave], c='black', linestyle='--') # 画出平均温度虚线\n",
" plt.legend()\n",
" plt.text(tem_max_date + 0.15, tem_max + 0.15, str(tem_max), ha='center', va='bottom', fontsize=10.5) # 标出最高温度\n",
" plt.text(tem_min_date + 0.15, tem_min + 0.15, str(tem_min), ha='center', va='bottom', fontsize=10.5) # 标出最低温度\n",
" plt.xticks(x)\n",
" plt.title('未来14天高温低温变化曲线图')\n",
" plt.xlabel('未来天数/天')\n",
" plt.ylabel('摄氏度/℃')\n",
" plt.show()\n",
"\n",
"\n",
"def change_wind(wind):\n",
" \"\"\"改变风向\"\"\"\n",
" for i in range(0, 14):\n",
" if wind[i] == \"北风\":\n",
" wind[i] = 90\n",
" elif wind[i] == \"南风\":\n",
" wind[i] = 270\n",
" elif wind[i] == \"西风\":\n",
" wind[i] = 180\n",
" elif wind[i] == \"东风\":\n",
" wind[i] = 360\n",
" elif wind[i] == \"东北风\":\n",
" wind[i] = 45\n",
" elif wind[i] == \"西北风\":\n",
" wind[i] = 135\n",
" elif wind[i] == \"西南风\":\n",
" wind[i] = 225\n",
" elif wind[i] == \"东南风\":\n",
" wind[i] = 315\n",
" return wind\n",
"\n",
"\n",
"def wind_radar(data):\n",
" \"\"\"风向雷达图\"\"\"\n",
" wind1 = list(data['风向1'])\n",
" wind2 = list(data['风向2'])\n",
" wind_speed = list(data['风级'])\n",
" wind1 = change_wind(wind1)\n",
" wind2 = change_wind(wind2)\n",
"\n",
" degs = np.arange(45, 361, 45)\n",
" temp = []\n",
" for deg in degs:\n",
" speed = []\n",
" # 获取 wind_deg 在指定范围的风速平均值数据\n",
" for i in range(0, 14):\n",
" if wind1[i] == deg:\n",
" speed.append(wind_speed[i])\n",
" if wind2[i] == deg:\n",
" speed.append(wind_speed[i])\n",
" if len(speed) == 0:\n",
" temp.append(0)\n",
" else:\n",
" temp.append(sum(speed) / len(speed))\n",
" print(temp)\n",
" N = 8\n",
" theta = np.arange(0. + np.pi / 8, 2 * np.pi + np.pi / 8, 2 * np.pi / 8)\n",
" # 数据极径\n",
" radii = np.array(temp)\n",
" # 绘制极区图坐标系\n",
" plt.axes(polar=True)\n",
" # 定义每个扇区的RGB值R,G,Bx越大对应的颜色越接近蓝色\n",
" colors = [(1 - x / max(temp), 1 - x / max(temp), 0.6) for x in radii]\n",
" plt.bar(theta, radii, width=(2 * np.pi / N), bottom=0.0, color=colors)\n",
" plt.title('未来14天风级图', x=0.2, fontsize=20)\n",
" plt.show()\n",
"\n",
"\n",
"def weather_pie(data):\n",
" \"\"\"绘制天气饼图\"\"\"\n",
" weather = list(data['天气'])\n",
" dic_wea = {}\n",
" for i in range(0, 14):\n",
" if weather[i] in dic_wea.keys():\n",
" dic_wea[weather[i]] += 1\n",
" else:\n",
" dic_wea[weather[i]] = 1\n",
" print(dic_wea)\n",
" explode = [0.01] * len(dic_wea.keys())\n",
" color = ['lightskyblue', 'silver', 'yellow', 'salmon', 'grey', 'lime', 'gold', 'red', 'green', 'pink']\n",
" plt.pie(dic_wea.values(), explode=explode, labels=dic_wea.keys(), autopct='%1.1f%%', colors=color)\n",
" plt.title('未来14天气候分布饼图')\n",
" plt.show()\n",
"\n",
"\n",
"def main():\n",
" plt.rcParams['font.sans-serif'] = ['SimHei'] # 解决中文显示问题\n",
" plt.rcParams['axes.unicode_minus'] = False # 解决负号显示问题\n",
" data14 = pd.read_csv('weather14.csv', encoding='gb2312')\n",
" print(data14)\n",
" tem_curve(data14)\n",
" wind_radar(data14)\n",
" weather_pie(data14)\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}