How to convert selected query to pandas DataFrame using PeeWee

Using ORI PeeWee, I have the following query:

query = DataModel.select()where(DataModel.field == "value")

Is there a way to convert queryto pandas DataFrame without iterating over all values? I am looking for a more "pythonic" way to do this.

+4
source share
1 answer

Assuming it queryhas a type peewee.SelectQuery, you can do:

df = pd.DataFrame(list(query.dicts()))
+12
source

Source: https://habr.com/ru/post/1671442/


All Articles