Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Example Analysis of Historical data of Air quality in python Development

Shulou Source: shulou.com Published: 2022-06-01 03:31:39 09月16日 Update

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!

Tags: Data analysis file format history air air quality quality hours pollutants monitoring stations articles storage pollution generation monitoring historical data examples development content Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MariaDB Shulou Information Microsoft macOS