You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a few methods to get a pandas DataFrame from a Pydantic model, but it will be just easier and more readable to not have any intermediate step.
Feature Description
Ideally, I could do something like:
from pydantic import BaseModel
class Item(BaseModel):
item_category: str
item_name: str
purchase_price: float
suggested_retail_price: float
item_number: int
margin: float
note: Optional[str] = None
And I will get a pandas df with columns item_category, item_name, purchase_price, suggested_retail_price, item_number, margin, note and on each row, one element of the list in response
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
There are a few methods to get a pandas DataFrame from a Pydantic model, but it will be just easier and more readable to not have any intermediate step.
Feature Description
Ideally, I could do something like:
from pydantic import BaseModel
class Item(BaseModel):
item_category: str
item_name: str
purchase_price: float
suggested_retail_price: float
item_number: int
margin: float
note: Optional[str] = None
response = : list[Item]
df = pd.from_pydantic(response)
And I will get a pandas df with columns
item_category, item_name, purchase_price, suggested_retail_price, item_number, margin, note
and on each row, one element of the list in responseAlternative Solutions
https://stackoverflow.com/questions/61814887/how-to-convert-a-list-of-pydantic-basemodels-to-pandas-dataframe
Additional Context
No response
The text was updated successfully, but these errors were encountered: