File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -178,20 +178,17 @@ def overwrite_with_results(
178178
179179 output_path = Path .cwd () / export_path .name
180180
181- preprocessed_dict = {doc .doc_id : doc for doc in preprocessed_docs }
181+ replacement_map = {
182+ doc .doc_id : " " .join (doc .tokens ) for doc in preprocessed_docs
183+ }
182184
183185 updated_df = self .df .copy ()
184186
185- for idx , row in updated_df .iterrows ():
186- doc_id = self ._extract_doc_id (row , self .id_column )
187-
188- preprocessed = preprocessed_dict .get (doc_id )
189-
190- if not preprocessed :
191- continue
192-
193- updated_df .at [idx , self .attribute ] = " " .join (preprocessed .tokens )
187+ updated_df [self .attribute ] = (
188+ updated_df [self .id_column ]
189+ .map (replacement_map )
190+ .fillna (updated_df [self .attribute ])
191+ )
194192
195193 updated_df .to_csv (output_path , index = False )
196-
197194 logger .info (f"CSV file successfully written to: { output_path } " )
You can’t perform that action at this time.
0 commit comments