Skip to main content

How would I turn this for loop output into a Pandas dataframe?

I have this code and I am having trouble figuring out how to put the for loop output into a dataframe. How could I take the for loop data and put it into a Pandas DataFrame?

Rows look like ('tag', 34)

select_stmt = select(Tag.tag, func.count('Tag.tag').label('CCount')).group_by(Tag.tag)
with Session(config.connect()) as session:
    exec = session.execute(select_stmt)
    for row in exec:
        print(row)


source https://stackoverflow.com/questions/73186044/how-would-i-turn-this-for-loop-output-into-a-pandas-dataframe

Comments