Read in 2 CSVs from separate folders, merge and export

# join cores & latts & longs for 7 properties

# Note — check if reading data from 30 cm layer or 120 cm layer

for p in range(0, len( property )):

# read in files and correct column headings

cov_df = pd.read_csv(‘C:/Users/MelZeppel/OneDrive — McCosker Contracting Pty Ltd/ML_development/2022_covariates_QGIS/’ + property.iloc[p] + ‘_ML_covariates_2208.csv’)

cov_df = cov_df.rename(columns = {‘core_numbe’:’core_number’})

property_name = cov_df[‘property_n’].iloc[0]

print(property_name)

layer_30 = pd.read_csv(‘C:/Users/MelZeppel/OneDrive — McCosker Contracting Pty Ltd/ML_development/carbon_point_join_files/point_join_’ + property_name + ‘_30_no_nulls.csv’)

# #join and export files

df = cov_df.merge(layer_30, on = ‘core_number’, how = ‘left’)

df = df.rename(columns = {‘cea_name_x’:’cea_name’, ‘sampling_r’:’sampling_round’})

df = df.drop(columns = {‘cea_name_y’})

lower_depth = df[‘lower_depth’].iloc[0].astype(str)

print(df.head() )

# df = df[[‘property_name’, ‘lower_depth’,’cea_name’, ‘strata_name’, ‘sampling_round’, ‘core_number’, ‘actual_latitude’, ‘actual_longitude’, ‘core_carbon_mass’]]

df.to_csv(‘C:/Users/MelZeppel/OneDrive — McCosker Contracting Pty Ltd/ML_development/2022_covariates_QGIS/’ + property.iloc[p] + lower_depth + ‘_ML_covariates_2208.csv’)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Melanie Zeppel

Women in AI: Agribusiness winner - 2022 Superstar of STEM 2022-2023 Scopus Sustainability Researcher of the Year - 2019