pandas-ai icon indicating copy to clipboard operation
pandas-ai copied to clipboard

using 'field_descriptions' is giving an error

Open vpurandara opened this issue 11 months ago • 3 comments

System Info

OS version: ubuntu-22.04 Python version: 3.9 The current version of pandasai being used: 2.0.2

🐛 Describe the bug

field_descriptions = {
'_id': 'The unique identifier for each lead',
'Status': 'Status of the lead',
'Created At': 'the date at which the lead is generated or created)'
}
    connector = PandasConnector(leads_df, field_descriptions=field_descriptions)

is giving an error

File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/connectors/pandas.py", line 52, in __init__
    self._load_df(self.config.original_df)
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandas/core/generic.py", line 5902, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'original_df'

@gventuri

vpurandara avatar Mar 03 '24 18:03 vpurandara

Same issue here (new user).

Workaround right now:

from pandasai.connectors import PandasConnector
from pandasai.connectors.pandas import PandasConnectorConfig

connector = PandasConnector(PandasConnectorConfig(original_df=leads_df), field_descriptions=field_descriptions)

According to source code, you can pass a dict also, something like {"original_df": leads_df} instead of instance of PandasConnectorConfig.

Issue seems to be in method PandasConnector._load_connector_config()

prise6 avatar Mar 03 '24 19:03 prise6

@prise6 This work around resolved the issue.

Thanks

vpurandara avatar Mar 04 '24 05:03 vpurandara

Thanks a lot for investigating @prise6, we'll fix it in the next version!

gventuri avatar Mar 07 '24 19:03 gventuri