{ "cells": [ { "cell_type": "code", "id": "initial_id", "metadata": { "collapsed": true, "ExecuteTime": { "end_time": "2025-04-30T06:40:32.138260Z", "start_time": "2025-04-30T06:40:32.136555Z" } }, "source": [ "from matplotlib import pyplot as plt\n", "import matplotlib as mpl\n", "import pandas as pd\n", "import seaborn as sns\n", "import warnings\n", "\n", "# 忽略所有警告\n", "warnings.filterwarnings(\"ignore\")" ], "outputs": [], "execution_count": 1 }, { "metadata": { "ExecuteTime": { "end_time": "2025-04-30T06:40:32.170204Z", "start_time": "2025-04-30T06:40:32.161366Z" } }, "cell_type": "code", "source": [ "# 设置中文字体(macOS 上常见中文字体)\n", "from matplotlib import font_manager as fm\n", "\n", "font_path = '/System/Library/Fonts/STHeiti Medium.ttc'\n", "my_font = fm.FontProperties(fname=font_path)\n", "mpl.rcParams['font.family'] = my_font.get_name()\n", "mpl.rcParams['axes.unicode_minus'] = False" ], "id": "cf27cc8494b7058", "outputs": [], "execution_count": 2 }, { "metadata": { "ExecuteTime": { "end_time": "2025-04-30T06:41:28.147681Z", "start_time": "2025-04-30T06:41:28.107064Z" } }, "cell_type": "code", "source": [ "data = pd.read_csv('./data/aqi.csv')\n", "data.head(3)" ], "id": "bca3f037ac5a1256", "outputs": [ { "data": { "text/plain": [ " 日期 AQI 质量等级 PM2.5含量(ppm) PM10含量(ppm) SO2含量(ppm) CO含量(ppm) \\\n", "0 2020/1/1 79 良 58 64 8 0.7 \n", "1 2020/1/2 112 轻度污染 84 73 10 1.0 \n", "2 2020/1/3 68 良 49 51 7 0.8 \n", "\n", " NO2含量(ppm) O3_8h含量(ppm) \n", "0 57 23 \n", "1 71 7 \n", "2 49 3 " ], "text/html": [ "
\n", " | 日期 | \n", "AQI | \n", "质量等级 | \n", "PM2.5含量(ppm) | \n", "PM10含量(ppm) | \n", "SO2含量(ppm) | \n", "CO含量(ppm) | \n", "NO2含量(ppm) | \n", "O3_8h含量(ppm) | \n", "
---|---|---|---|---|---|---|---|---|---|
0 | \n", "2020/1/1 | \n", "79 | \n", "良 | \n", "58 | \n", "64 | \n", "8 | \n", "0.7 | \n", "57 | \n", "23 | \n", "
1 | \n", "2020/1/2 | \n", "112 | \n", "轻度污染 | \n", "84 | \n", "73 | \n", "10 | \n", "1.0 | \n", "71 | \n", "7 | \n", "
2 | \n", "2020/1/3 | \n", "68 | \n", "良 | \n", "49 | \n", "51 | \n", "7 | \n", "0.8 | \n", "49 | \n", "3 | \n", "