Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: type cast to dict of SmartDataframe (#532) #543

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pandasai/smart_dataframe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from ..helpers.logger import Logger
from ..helpers.df_config_manager import DfConfigManager
from ..helpers.from_google_sheets import from_google_sheets
from typing import List, Union, Optional
from typing import List, Union, Optional, Literal
from ..middlewares.base import Middleware
from ..helpers.df_info import DataFrameType, df_type
from .abstract_df import DataframeAbstract
Expand Down Expand Up @@ -248,6 +248,16 @@ def validate(self, schema: pydantic.BaseModel):
df_validator = DfValidator(self.original_import)
return df_validator.validate(schema)

def to_dict(
self,
orient: Literal[
"dict", "list", "series", "split", "tight", "records", "index"
] = "dict",
into: type[dict] = dict,
index: bool = True,
) -> dict | list[dict]:
pass

@property
def datalake(self):
return self._dl
Expand Down
4 changes: 4 additions & 0 deletions pandasai/smart_dataframe/abstract_df.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from typing import overload


class DataframeAbstract:
# Columns
@property
Expand Down Expand Up @@ -152,6 +155,7 @@ def to_json(self, path):
def to_sql(self, name, con):
raise NotImplementedError

@overload
def to_dict(self, orient):
raise NotImplementedError

Expand Down