|
import os |
|
import pandas as pd |
|
|
|
basedir = './' |
|
dirs = ['1.Raw(PM)','2.Raw(PM+Met)','3.Clean(PM+Met)','4.Grid(PM+Met)'] |
|
months = ['Nov2020', 'Dec2020', 'Jan2021'] |
|
months_fmt = {'Nov2020':'2020-11-{:02d}_all', 'Dec2020':'2020-12-{:02d}_all', 'Jan2021':'2021-01-{:02d}_all'} |
|
|
|
def read(path, D): |
|
if os.path.exists(path): |
|
d = pd.read_csv(path) |
|
D = pd.concat((D,d)) |
|
return D |
|
|
|
for dir in dirs: |
|
D = None |
|
for month in months: |
|
if 'Raw' not in dir: |
|
D = read(os.path.join(basedir, dir, month+'.csv.gz'), D) |
|
else: |
|
for file in range(1,32): |
|
D = read(os.path.join(basedir, dir, month, months_fmt[month].format(file) + '.csv.gz'), D) |
|
print('{}: Shape {}, Mean PM2.5 {}'.format(dir, D.shape, D.pm2_5.mean())) |
|
|
|
print('Done') |