In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "python air quality data example analysis", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "python air quality data example analysis" bar!
After calculating the daily average AQI, according to the AQI data, calculate the corresponding daily pollution level, you need to add a new column to the one-month data, and directly add square brackets on the DataFrame.
Monthdata ['level']
In the use of map function, according to the data value of AQI, calculate the corresponding pollution level, map can use the function.
Monthdata ['level'] = monthdata [' AQI'] .map (ComputeLevel)
Aqilevels = np.array ([.])
Levels = np.array ([u 'excellent', u 'good', u 'mild pollution'
U' moderate pollution', u' heavy pollution', u' serious pollution', u' no data'])
Def ComputeLevel (x):
If (not math.isnan (x)):
Index = np.where (aqilevels > = x)
Return levels [index [0] [0]]
Else:
Return'no data'
Fill the part without data with no data, so that it can be easily viewed when the data is counted.
Monthdata ['level'] = monthdata [' level'] .fillna ('innumerable data')
Next, according to the pollution level, count the data in DataFrame and calculate the number of days of each pollution level per month, in which the level column name is converted to count, and level is used as the column name, not as an index.
Levelscount = pd.DataFrame (monthdata ['level'].
Groupby (monthdata ['level']) .count ()
Levelscount = levelscount.rename (columns= {'level':' count'})
Levelscount = levelscount.reset_index ('level')
Use matplotlib to count the number of days at each level per month and display it in a bar chart.
Fig = plt.figure (figsize= (8,5))
Dataax = fig.add_subplot (1,1,1)
Dataax.bar (inde, levelscount ['count'] .tolist ()
0.35, color=lecolor, edgecolor='white') Thank you for your reading, the above is the content of "python Air quality data example Analysis". After the study of this article, I believe you have a deeper understanding of the python air quality data example analysis, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.