Change deprecated DataFrame append statements to concat

This commit is contained in:
Steve Baskauf 2024-03-29 09:23:39 -05:00
parent df27999d54
commit ce4f0342bf
1 changed files with 9 additions and 4 deletions

View File

@ -55,7 +55,8 @@ for term_list_index in range(len(term_lists)):
accumulated_frame = versions_df.copy()
else:
# append subsequent term lists data to the DataFrame
accumulated_frame = accumulated_frame.append(versions_df.copy(), sort=True)
#accumulated_frame = accumulated_frame.append(versions_df.copy(), sort=True)
accumulated_frame = pd.concat([accumulated_frame, versions_df], sort=True)
# Special procedure for obsolete terms
# Retrieve versions metadata
@ -84,7 +85,9 @@ for row_index,row in versions_df.iterrows():
# Add the curren term IRI list to the DataFrame as the term_iri column
versions_df['term_iri'] = term_iri_list
# Add the obsolete terms DataFrame to the accumulated DataFrame
accumulated_frame = accumulated_frame.append(versions_df.copy(), sort=True)
#accumulated_frame = accumulated_frame.append(versions_df.copy(), sort=True)
accumulated_frame = pd.concat([accumulated_frame, versions_df], sort=True)
accumulated_frame.reset_index(drop=True, inplace=True) # reset the row indices to consecutive starting with zero
accumulated_frame.fillna('', inplace=True) # replace all missing values with empty strings
@ -166,7 +169,8 @@ for qrg_index,qrg_row in qrg_df.iterrows():
for row_index,row in normative_doc_df.iterrows():
if (qrg_row['recommended_term_iri'] == row['term_iri']) and (row['status'] == 'recommended'):
found = True
built_rows_df = built_rows_df.append(row)
#built_rows_df = built_rows_df.append(row)
built_rows_df.loc[len(built_rows_df.index)] = row
remaining_rows_df.drop(row['iri'], axis=0, inplace=True)
break
if not found:
@ -178,7 +182,8 @@ sorted_output = remaining_rows_df.iloc[remaining_rows_df.iri.str.lower().argsort
# Concatenate ordered terms and remaining versions
#normative_doc_df = built_rows_df.append(remaining_rows_df)
normative_doc_df = built_rows_df.append(sorted_output)
#normative_doc_df = built_rows_df.append(sorted_output)
normative_doc_df = pd.concat([built_rows_df, sorted_output])
# Save the normative document DataFrame as a CSV
normative_doc_df.to_csv('../vocabulary/term_versions.csv', index = False)