Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- # CONFIG
- input_file_w_nuls = "data/af_daily.csv"
- file_wo_nuls = "data/af_daily_nn.csv"
- start_date = "9/11/2001" # Next time give me dates in the CSV, please
- resample_type = "M" # Resample to monthly periods
- def remove_nul(f_in, f_out):
- input = open(f_in, "rb")
- data = input.read()
- input.close()
- output = open(f_out, "wb")
- output.write(data.replace(b"\x00", b""))
- output.close()
- remove_nul(input_file_w_nuls, file_wo_nuls) # Don't fuck with me, NULs
- af_input = pd.read_csv(file_wo_nuls, header=None) # Fuck the headers
- date_index = pd.date_range(start_date, periods=len(af_input.index), freq="D") # We have daily data, hence the daily data range
- af_input=af_input.as_matrix(columns=None).ravel() # Convert DataFrame to numpy array
- airflow_data = pd.Series(af_input, index=date_index) # Do the magic
- airflow_data = airflow_data.resample(resample_type)
- # ... and a whole bunch of code below here, not really important
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement