mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-23 15:19:33 +00:00
Update dataframe.py (#28871)
community: optimize DataFrame document loader **Description:** Simplify the `lazy_load` method in the DataFrame document loader by combining text extraction and metadata cleanup into a single operation. This makes the code more concise while maintaining the same functionality. **Issue:** N/A **Dependencies:** None **Twitter handle:** N/A
This commit is contained in:
parent
cb4e6ac941
commit
32917a0b98
@ -21,9 +21,8 @@ class BaseDataFrameLoader(BaseLoader):
|
|||||||
"""Lazy load records from dataframe."""
|
"""Lazy load records from dataframe."""
|
||||||
|
|
||||||
for _, row in self.data_frame.iterrows():
|
for _, row in self.data_frame.iterrows():
|
||||||
text = row[self.page_content_column]
|
|
||||||
metadata = row.to_dict()
|
metadata = row.to_dict()
|
||||||
metadata.pop(self.page_content_column)
|
text = metadata.pop(self.page_content_column)
|
||||||
yield Document(page_content=text, metadata=metadata)
|
yield Document(page_content=text, metadata=metadata)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user