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
7
votes
3 answers

Creating a pandas pivot table to count number of times items appear in a list together

I am trying to count the number of times users look at pages in the same session. I am starting with a data frame listing user_ids and the page slugs they have visited: user_id page_view_page_slug 1 slug1 1 slug2 1 slug3 1 …
young_matt
  • 73
  • 4
7
votes
2 answers

Google Sheets pivot table count number of occurrence for each value of data

How can I get a pivot table in Google sheets with a column showing number of time a value has occurred in a column? I know it can be done using the countif function but I want to do it using a pivot table.
farooq
  • 170
  • 1
  • 1
  • 8
7
votes
1 answer

create excel pivot tables from R

I am performing a number of data transformations within R. My manager wants the output to be an excel export with an excel pivot table, with all the features that an excel pivot table offers (such as double clicking to see data makeup). Does anyone…
mutaween464
  • 253
  • 2
  • 8
7
votes
1 answer

Pandas Dataframe: to_dict() poor performance

I work with apis that return large pandas dataframes. I'm not aware of a fast way to iterate through the dataframe directly so I cast to a dictionary with to_dict(). After my data is in dictionary form, the performance is fine. However, the…
7
votes
3 answers

java.io.EOFException: Unexpected end of ZLIB input stream using Apache POI

I try to create Excel Pivot Table using Apache POI. At the moment, when I try to write data in a workbook workbook.write(fileOut); I get exception org.apache.poi.ooxml.POIXMLException: java.io.EOFException: Unexpected end of ZLIB input…
7
votes
1 answer

Float values when pivoting dataframe of integers (pandas - python)

I have a huge pandas dataframe, shaped like this example: new_id hour names values 0 0 mark 5 0 0 matt 4 0 0 alex 3 1 0 roger 2 1 0 arthur 7 1 1 alf 8 2 1 ale 6 3 1 …
sato
  • 768
  • 1
  • 9
  • 30
7
votes
4 answers

adding filter to pandas pivot table

I would like to add a filtering condition to a pivot table, like this: (Select the values of v2 equal to 'A') pd.pivot_table(df,index=['v1'],columns=['v2'=='A'],values=['v3'],aggfunc='count') Is that possible?
progster
  • 877
  • 3
  • 15
  • 27
7
votes
2 answers

Extracting data from pivot table vba

I have a pivot table to aggregate "coverage" on "part" only for accepted parts. I want then to extract the "sum of coverage" to another sheet. I wrote the following macro: Sub Pull_data() 'Update the pivot…
L.Dutch
  • 926
  • 3
  • 17
  • 38
7
votes
3 answers

Unable to set the Visible property of the PivotItem class when setting PivotItem.Visible = false

I want to make PivotItem.Visible = False but I keep getting an error: Unable to set the Visible property of the PivotItem class I tried all the solutions I found in the internet but none seems to work Sub FloorCompareSetter() Dim pt As…
Sabir Moglad
  • 121
  • 1
  • 3
  • 9
7
votes
2 answers

pandas slicing multiindex dataframe

I want to slice a multi-index pandas dataframe here is the code to obtain my test data: import pandas as pd testdf = { 'Name': { 0: 'H', 1: 'H', 2: 'H', 3: 'H', 4: 'H'}, 'Division': { 0: 'C', 1: 'C', 2: 'C', 3: 'C', 4:…
muon
  • 12,821
  • 11
  • 69
  • 88
7
votes
3 answers

SQL Server Dynamic Pivot Column Names

For the necessity of my application, I must return the column names of a query as the very first row. Now I must PIVOT this result in order to UNION it with my result set, but the difficult part is: it must be dynamic, so if I ever add new columns…
user3472897
  • 240
  • 2
  • 3
  • 11
7
votes
4 answers

Laravel Removing Pivot data in many to many relationship

Not sure if I set this up correctly. In Laravel I'm creating two models with a many-to-may relationship The models are Item and Tags. Each one contains a belongsTo to the other. When I run a query like so: Item::with('tags')->get(); It returns the…
Rob
  • 10,851
  • 21
  • 69
  • 109
7
votes
6 answers

correct way to create a pivot table in postgresql using CASE WHEN

I am trying to create a pivot table type view in postgresql and am nearly there! Here is the basic query: select acc2tax_node.acc, tax_node.name, tax_node.rank from tax_node, acc2tax_node where tax_node.taxid=acc2tax_node.taxid and…
mojones
  • 1,640
  • 3
  • 15
  • 26
7
votes
6 answers

PivotTable Do not show subtotals

I am converting a table into Pivot and then to a CSV file. I want to remove the subtotals of the pivot table. So far: this is my progress. MACRO CreatePivot: Sub CreatePivot() ' Creates a PivotTable report from the table on Sheet1 ' by using the…
ingalcala
  • 1,785
  • 3
  • 14
  • 24
7
votes
3 answers

How do I convert a pandas pivot table to a dataframe

I want to use a pivot table to summarise a dataset and then be able to access the information in the pivot table as if it were a DataFrame. Consider a hierarchical dataset with patients being treated in a hospital and hospitals situated in…
user1718097
  • 4,090
  • 11
  • 48
  • 63