Questions tagged [pivot-table]

A "pivot table" is a method of summarizing data in tabular form. Typically, these have a category column in the left hand side, and multiple summary columns to the right. Each different category will have its own row. Be sure to include the relevant language tag (python, excel, R, postgreSQL etc.) on your question.

A "pivot table" is a method of summarizing data in tabular form. Typically, these have a category column in the left hand side, and multiple summary columns to the right. Each different category will have its own row.

Pivot tables are typically found in data visualization programs, including spreadsheets and business intelligence. Note that a "pivot table" is also known as a "cross tab" or "cross tabulation".

Resources:

8105 questions
10
votes
4 answers

Better way of Seeding a Pivot Table

I have the following tables users , roles and the pivot table role_user with the following table structure users id username password roles id role role_user id role_id user_id
lozadaOmr
  • 2,565
  • 5
  • 44
  • 58
10
votes
1 answer

Pandas Handling Missing Values when going from Data Frame to Pivot Table

Given the following pandas data frame: df = pd.DataFrame({'A': ['foo' ] * 3 + ['bar'], 'B': ['w','x']*2, 'C': ['y', 'z', 'a','a'], 'D': rand.randn(4), }) print df.to_string() """ A B C D 0 foo …
Paul
  • 7,155
  • 8
  • 41
  • 40
10
votes
5 answers

update pivot table in case of many to many relation laravel4

I have started working with Laravel4 recently. I am facing some problem while updating pivot table data, in case of many to many relation. The situation is: I have two table: Product, ProductType. The relation between them is Many to many. My…
Sameer
  • 1,764
  • 4
  • 16
  • 21
10
votes
2 answers

SQL - Pivot table and group by not working

I have a table as follows: Product #users Date Count Type prodA 29 2013-02-27 113 Document prodA 31 2013-03-02 152 Extraction prodB 17 2013-02-26 40 Document prodB …
viv_acious
  • 2,429
  • 9
  • 34
  • 55
10
votes
1 answer

Dynamic Pivot Columns in SQL Server

I have a table named Property with following columns in SQL Server: Id Name There are some property in this table that certain object in other table should give value to it. Id Object_Id Property_Id Value I want to make a pivot table…
Ashkan
  • 1,643
  • 5
  • 23
  • 45
9
votes
1 answer

How to Delete the Subtotals from Google Sheet's Pivot Table

How to Delete the Grand Total and Subtotals from Google Sheet's Pivot Table?
lostwanderer
  • 143
  • 1
  • 1
  • 7
9
votes
1 answer

VBA - Connection Range Count Incorrect With Second Window Maximized

Take a file, with a pivot table and some data/filter: Place the following method in the "BeforeClose" method: Private Sub Workbook_BeforeClose(Cancel As Boolean) 'ThisWorkbook.connections(1).Ranges.count End Sub Now if you close this…
David Rogers
  • 2,601
  • 4
  • 39
  • 84
9
votes
1 answer

Pandas pivot_table with pd.grouper and Margins

Margins=True will not work in Pandas pivot_table when columns is set as pd.grouper datetime. this is my code which works as expected-- p = df.pivot_table(values='Qty', index=['ItemCode', 'LineItem'],columns=pd.Grouper(key = 'Date', freq='W'),…
9
votes
2 answers

Save a pivottablejs figure to file

I have started using the package pivottablejs to manipulate and visualize pivot tables in python. from pivottablejs import pivot_ui pivot_ui(df) # where df is a pandas dataframe will produce an interactive pivot table/plot in a jupyter…
VinceP
  • 2,058
  • 2
  • 19
  • 29
9
votes
3 answers

Setting value to .Function using VBA

I currently have a function set in place which will change all values of a selected pivot table to average. It works fine, and I have assembled a form which passes a value which works fine as well. What I would like to do at this point is make it…
Brad
  • 1,450
  • 2
  • 16
  • 37
9
votes
2 answers

Create contingency table Pandas with counts and percentages

Is there a better way to create a contingency table in pandas with pd.crosstab() or pd.pivot_table() to generate counts and percentages. Current solution cat=['A','B','B','A','B','B','A','A','B','B'] target =…
iboboboru
  • 1,112
  • 2
  • 10
  • 21
9
votes
2 answers

removing the name of a pandas dataframe index after appending a total row to a dataframe

I have calculated a series of totals tips by day of a week and appended it to the bottom of totalspt dataframe. I have set the index.name for the totalspt dataframe to None. However while the dataframe is displaying the default 0,1,2,3 index it…
yoshiserry
  • 20,175
  • 35
  • 77
  • 104
9
votes
3 answers

Laravel: How to get single pivot row by key id

I have a many-to-many relation set on my User and Notification Eloquent models. This way I can access the pivot table - user_notifications - as follows: $user = User::find(1); foreach ($user->notifications() as $n) { echo…
lesssugar
  • 15,486
  • 18
  • 65
  • 115
9
votes
3 answers

Is there any way to create a Pivot Table in Excel using Apache POI?

I am currently working on the automation of Excel, and add such I have made a good use of the Apache POI library. As I have so much data stored in my excel workbook in various columns, that I'm trying to create a pivot table. Is there any way to…
SabareeshSS
  • 1,361
  • 2
  • 11
  • 20
9
votes
2 answers

How to pivot? How to convert multiple rows into one row with multiple columns?

I have two tables which I want to combine. The first table is with clients and the other with products. Currently I have 22 products, but I want to have a flexible DB design so instead of having 22 columns in the product DB, I have 1 row for each…
user2218856
  • 117
  • 1
  • 2
  • 6