I have hourly temperature and rainfall observations from nearly 2000 stations. Each station has its own csv file which temporally extend from May to August 2022. First by using the globe, I convert the hourly data to averaged daily and save new csv file named as "StationName - edited.csv".
df.head()
Out[5]:
date station lat lon Rain Temp
0 2022-05-01 72750494999 46.5475 -93.67667 100.0 109.4
1 2022-05-02 72750494999 46.5475 -93.67667 93.0 96.8
2 2022-05-03 72750494999 46.5475 -93.67667 93.0 96.8
3 2022-05-04 72750494999 46.5475 -93.67667 100.0 96.8
4 2022-05-05 72750494999 46.5475 -93.67667 87.0 98.6
Next I want to put all these 2000 csv's in a one file using concat command. However, some of these csv's (nearly 150) does not have rainfall observation so their Rain column in the csv is empty, and manually finding them through 2000 files is vert tedious task.
Can anyone suggest a solution for me to eliminate this csv's files (the one with missing values) from entering the concat command, or only used those which have both columns. For example, I got the idea of indicating a IF in the code so that if the csv has missing value the code drop this csv from the concat command!
import numpy as np
import pandas as pd
# Read all the csv if Folder
import glob
filenames = sorted(glob.glob('*.csv'))
# Create an empty dataset
e = pd.DataFrame()
for f in filenames:
# read the variables
df = pd.read_csv(f, index_col=None)
# I think I should add something here!
e = pd.concat([e, df], axis=0)