table_loader
langroid/parsing/table_loader.py
read_tabular_data(path_or_url, sep=None)
¶
Reads tabular data from a file or URL and returns a pandas DataFrame. The separator is auto-detected if not specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_or_url |
str
|
Path or URL to the file to be read. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Data from file or URL as a pandas DataFrame. |
Raises:
Type | Description |
---|---|
ValueError
|
If the data cannot be read or is misformatted. |
Source code in langroid/parsing/table_loader.py
describe_dataframe(df, filter_fields=[], n_vals=10)
¶
Generates a description of the columns in the dataframe,
along with a listing of up to n_vals
unique values for each column.
Intended to be used to insert into an LLM context so it can generate
appropriate queries or filters on the df.
Args: df (pd.DataFrame): The dataframe to describe. filter_fields (list): A list of fields that can be used for filtering. When non-empty, the values-list will be restricted to these. n_vals (int): How many unique values to show for each column.
Returns: str: A description of the dataframe.