Newer
Older

Jérémy AUCLAIR
committed
with lock:
pbar.update(round(shared_value.value - pbar.n))
# Wait for all processes to complete
for result in results:
result.wait()
# Close the pool
pool.close()
pool.join()
Jeremy Auclair
committed

Jérémy AUCLAIR
committed
rain_list = []
ET0_list = []
for i in range(max_cpu):
rain_list.extend(results[i].get())
ET0_list.extend(results[max_cpu + i].get())
del results, result
Jeremy Auclair
committed
# Collect results in a single dataframe

Jérémy AUCLAIR
committed
weather_dataframe = pd.DataFrame(rain_list, columns = ['date', 'id', 'Rain', 'LC'])
weather_dataframe['ET0'] = pd.DataFrame(ET0_list, columns = ['date', 'id', 'ET0', 'LC'])['ET0']
Jeremy Auclair
committed
# Reorder columns
weather_dataframe = weather_dataframe.reindex(columns = ['date', 'id', 'Rain', 'ET0', 'LC'])
# Format datatypes
weather_dataframe['Rain'] = np.round(weather_dataframe['Rain']).astype(int)
weather_dataframe['ET0'] = np.round(weather_dataframe['ET0']).astype(int)
# Change date type
weather_dataframe['date'] = pd.to_datetime(weather_dataframe['date'])
# Save dataframe to csv
weather_dataframe.to_csv(save_path, index = False)
return None