mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-15 00:02:59 +00:00
@@ -15,6 +15,7 @@ from __future__ import annotations
|
||||
import pandas as pd
|
||||
from .exceptions import MissingValueError, MissingColumnError
|
||||
|
||||
|
||||
def contextualize(raw_df: pd.DataFrame) -> Contextualizer:
|
||||
"""Create a Contextualizer object for the given DataFrame.
|
||||
|
||||
@@ -85,6 +86,7 @@ def contextualize(raw_df: pd.DataFrame) -> Contextualizer:
|
||||
|
||||
class Contextualizer:
|
||||
"""Create context windows from a DataFrame. See [lancedb.context.contextualize][]."""
|
||||
|
||||
def __init__(self, raw_df):
|
||||
self._text_col = None
|
||||
self._groupby = None
|
||||
@@ -144,12 +146,16 @@ class Contextualizer:
|
||||
raise MissingColumnError(self._text_col)
|
||||
|
||||
if self._window is None or self._window < 1:
|
||||
raise MissingValueError("The value of window is None or less than 1. Specify the "
|
||||
"window size (number of rows to include in each window)")
|
||||
raise MissingValueError(
|
||||
"The value of window is None or less than 1. Specify the "
|
||||
"window size (number of rows to include in each window)"
|
||||
)
|
||||
|
||||
if self._stride is None or self._stride < 1:
|
||||
raise MissingValueError("The value of stride is None or less than 1. Specify the "
|
||||
"stride (number of rows to skip between each window)")
|
||||
raise MissingValueError(
|
||||
"The value of stride is None or less than 1. Specify the "
|
||||
"stride (number of rows to skip between each window)"
|
||||
)
|
||||
|
||||
def process_group(grp):
|
||||
# For each group, create the text rolling window
|
||||
|
||||
Reference in New Issue
Block a user