In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use Python to see the air quality in Beijing, Shanghai, Guangzhou and Shenzhen in 2018. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
I do not know when, "thick load, continuous self-improvement" has become a fog of virtue, self-improvement does not absorb.
No picture, no truth, the following picture is proof.
Let's use Python to take a look at the air quality analysis of Beijing, Shanghai, Guangzhou and Shenzhen in 2018.
The picture on the left is in February last year, this kind of air is really rare!
The one on the right is complaining and my first time buying a mask!
The mask is OK, because at that time to do the curriculum, often have to run two campuses, basically the air is not good, I will put on.
The topic seems to be about hydraulic and pneumatic transmission system, hand-drawn A 0 diagram.
It should have been almost two years ago, and time flies.
So this time, we first analyze the air quality in Tianjin in 2017, and then go north to Guangzhou and Shenzhen.
/ 01 / Web page analysis
There is no anti-crawling on the website, so just grab the information directly.
See, the proper serious pollution, the mask bought in December 2016 came in handy!
Here is a simple way to popularize the knowledge about AQI,PM2.5.
I'm going back to my old business, and my PPT level is still very low.
/ 02 / data acquisition
The acquisition code is shown below.
Import time
Import requests
From bs4 import BeautifulSoup
Headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'
}
For i in range (1,13):
Time.sleep (5)
# convert 1 to 01
Url = 'http://www.tianqihoubao.com/aqi/tianjin-2017' + str ("d"% I) +' .html'
Response = requests.get (url=url, headers=headers)
Soup = BeautifulSoup (response.text, 'html.parser')
Tr = soup.find_all ('tr')
# remove the label bar
For j in tr [1:]:
Td = j.find_all ('td')
Date = td [0] .get _ text () .strip ()
Quality_grade = td [1] .get _ text () .strip ()
AQI = td [2] .get _ text () .strip ()
AQI_rank = td [3] .get _ text () .strip ()
PM = td [4] .get _ text ()
With open ('air_tianjin_2017.csv',' axioms, encoding='utf-8-sig') as f:
F.write (Date +','+ Quality_grade +','+ AQI +','+ AQI_rank +','+ PM +'\ n')
The data was obtained successfully.
/ 03 / Tianjin
Also not on the source code, it is necessary to say a wave here, because I think the source code typesetting will not look good.
Secondly, I want to follow the fine tradition of mixing P circles (PPT) before, and love to share. You deserve Baidu cloud disk.
So the official account returns to the weather. You can get all the visual source code and related files.
I used to download the masterpiece of PPT every day and watch it, but unfortunately, the level of PPT is still so lame.
01 AQI annual trend chart
92.5 is the average annual AQI. From the above popular science knowledge, we can see that the overall air quality in Tianjin in 2017 can only be the lower level of "good", close to mild pollution.
02 AQI monthly average trend chart
From the monthly trend chart, we can see that the air quality in January is the worst and the air quality in August is the best.
03 AQI quarterly box chart
A box chart that shows a set of statistical charts of data dispersion.
There are maximum, minimum, median and two quartiles in the data.
It can be seen here that the average gap of quarterly AQI in Tianjin in 2017 is not very large.
But there are obvious fluctuations in the first, second and fourth quarters, and the air quality sometimes becomes very poor.
04 PM2.5 annual trend chart
59.87 is the average annual PM2.5, which has far exceeded the national secondary standard limit of 35.
In fact, the impression that Tianjin leaves me is that the weather is often gray and often changes colors, such as yellow.
It rains less than a few times a year, and it's dry. So the lowest value was 11, and I guess it was windy at that time.
05 PM2.5 monthly average trend chart
The trend is similar to that of AQI, with the highest in January and the lowest in August.
06 PM2.5 quarterly box chart
To tell you the truth, after looking at this picture, I don't know how the "eldest brothers" and "sisters" in Tianjin achieve self-improvement without smoking.
Basically, it has exceeded the standard in four quarters, and it is estimated that it does not exceed the standard only a few times a year.
07 PM2.5 index calendar chart
The average daily PM2.5 national secondary standard is 75. From the above thermal map, it is basically more than half of the slight pollution.
In addition, January is still a hard-hit area, the sky is yellow.
In fact, when it comes to haze, it is basically waiting for the dormitory. And January is the examination month, which happens to be the dormitory preview textbook.
08 annual air quality in Tianjin
"good" and "mild pollution" account for the majority, and "excellent" can only shiver in the corner, which is enough to show the difference in the air.
However, there is still a class, who said that the dormitory and the classroom were close at that time (less than 5 minutes walk).
/ 04 / North, Shanghai, Guangzhou and Shenzhen
01 annual trend chart of Beijing, Guangzhou and Shenzhen AQI
The minimum monthly AQI in Beijing is only about 50, which seems to be below "excellent" for the whole of this year.
However, compared with a few years ago, the air in Beijing, Tianjin and Hebei has been much better, really.
Shanghai is similar to Guangzhou, while Shenzhen is in sharp contrast to Beijing.
02 annual trend chart of PM2.5 from Beijing, Guangzhou and Shenzhen
Beijing is as high-profile as ever.
03 annual air quality in Beijing, Shanghai, Guangzhou and Shenzhen
Shenzhen is almost always "excellent" and "good". Shanghai and Guangzhou are the same as above, and Beijing already has a lot of "excellent".
So what is the air quality in your city?
On how to use Python to see the air quality of Beijing, Shanghai, Guangzhou and Shenzhen in 2018, so much for sharing here. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.