A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/tomasd/pandas-sqlalchemy-pivot below:

tomasd/pandas-sqlalchemy-pivot: Pivot tables for sqlalchemy

Provides pivot functionality for databases. Pivot aggregates are created directly in the database. Reshaping into pivot is done in the pandas framework.

table.insert().execute(customer_id=1, yearmonth='201001', gender='male', price=10)
table.insert().execute(customer_id=2, yearmonth='201001', gender='male', price=5)
table.insert().execute(customer_id=3, yearmonth='201001', gender='female', price=10)

select = sqlalchemy.select(table.c.yearmonth, table.c.gender, table.c.price)

table = pivots.pivot_table_from_select(
            select,
            rows='yearmonth', cols='gender', values='price'
        )

print table
            price
gender     female  male
yearmonth
201001         10    15

For more examples look at tests.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4