# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3 (ipykernel)
#     language: python
#     name: python3
# ---

import csv
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

df = pd.read_csv ('/home/prabu/Research/API_PM_data/hourly_88101_2021.csv')

# +
# Texas Tarrant 32.759154 -97.342332 index(3239913-3245442) from 2021-01-01 00:00 to 2021-08-31 23:00
# finding Fort Worth data 

"""
for index, row in df.iterrows():
    a = str(row['State Name']) 
    if a == 'Texas':
        print(index, 'Texas', row['County Name'], row['Latitude'], row['Longitude'], row['Date Local'], \
              row['Time Local'], row['Date GMT'], row['Time GMT'], row['Sample Measurement'])  
"""

# State = Texas
# County = Tarrant
# City = Fort Worth
# Latitude = 32.759154
# Longitude = -97.342332
# Index = 3239913 - 3245442
# Date = 2021-01-01 00:00 - 021-08-31 23:00

# +
# Creating new dataFrame with Fort Worth data

dfFW = df[3239913:3245442]
# df_new.to_csv(r'/home/prabu/Research/API_PM_data/PM_TX.csv', sep='\t', encoding='utf-8', header='true')

# +

dfFW.POC = pd.to_datetime(df_new['Date GMT'] + df_new['Time GMT'], format='%Y-%m-%d%H:%M') # combine date and time reasign to POC column
dfFW2 = dfFW.rename(columns={"POC": "DateTime", "Sample Measurement": "PM2.5"})
dfFW3 = dfFW2[['DateTime', 'Latitude', 'Longitude', 'PM2.5']]
# dfFW3.to_csv(r'/home/prabu/Research/API_PM_data/PM_TX.csv', sep='\t', encoding='utf-8', header='true')
# -

dfFW3

dfFW3.plot(x="DateTime", y="PM2.5");

np.max(dfFW3["PM2.5"])



StarcoderdataJupyterScriptsDedupFiltered