Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Historical data of Air quality in python Development

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Xiaobian to share with you the example analysis of historical data of air quality in python development, I believe most people still do not know how, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!

The historical air quality data format is stored in csv format. The hourly data of each monitoring station is generated by day. Some of the hourly data are incomplete due to the published server end, and some of the daily data are also incomplete.

Download the compressed package of Beijing monitoring stations in 2017, beijing_20170101-20171231, with a total of 730 files. api, pm2.5, pm10 and iaqi data of two types of pollutants of each station are stored in beijing_all_xxxxxx, iaqi data of other pollutants and pollutants are stored in beijing_extra_xxxxxx. Generally, the file size is 1kb, which is an abnormal data file.

Exception data file:

Python class library: csv data analysis using pandas, pandas can directly open csv data into a data format with industry index.

import pandas as pd

pd.read_csv(_filePath)

where NaN is nonexistent data.

Filter the data, only keep the data of one monitoring station, use all kinds of row and column control of pandas, select column data, filter the row data, create column data, sort data.

pd_filterCol = _dfdata[['date', 'hour', 'type', _station]]

filterrow = pd_filterCol[pd_filterCol['type'] == 'AQI']

filterrow['datetime'] = filterrow['date'].map(str)

alldaydata = alldaydata.sort_values(by="datetime", ascending=True)

Generate new dataframe data, detailed row and column data.

Use matplotlib to generate hourly aqi change chart, need to refer to matplotlib class library, because the analysis uses date format data, to refer to dates for processing, add line chart, set the style of line chart.

import matplotlib.pyplot as plt

import matplotlib

import matplotlib.dates as mdatesfig = plt.figure(figsize=(8, 5))

dataax = fig.add_subplot(1, 1, 1)

dataax.plot(daydata['datetime'].tolist(), daydata['AQI'].tolist(), lw=2, c='r', label=u'AQI',

marker='o', mec='b', mfc='w')....

The above is all the content of this article "Example analysis of air quality historical data in python development", thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report