Skip to content

ENH: Adding pd.from_pydantic #61513

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

Open
1 of 3 tasks
JavierLopezT opened this issue May 29, 2025 · 0 comments
Open
1 of 3 tasks

ENH: Adding pd.from_pydantic #61513

JavierLopezT opened this issue May 29, 2025 · 0 comments
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@JavierLopezT
Copy link

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 response

Alternative Solutions

https://stackoverflow.com/questions/61814887/how-to-convert-a-list-of-pydantic-basemodels-to-pandas-dataframe

Additional Context

No response

@JavierLopezT JavierLopezT added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

1 participant