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
19
votes
2 answers

Pandas pivot_table, sort values by columns

I am a new user to Pandas and I love it! I am trying to create a pivot table in Pandas. Once I have pivot table the way I want, I would like to rank the values by the columns. I've attached an image from Excel as it is easier to see in tabular…
Kah
  • 492
  • 1
  • 5
  • 17
19
votes
4 answers

melt / reshape in excel using VBA?

I'm currently adjusting to a new job where most of the work I share with colleagues is via MS Excel. I am using pivot tables frequently, and therefore need "stacked" data, precisely the output of the melt() function in the reshape (reshape2)…
baha-kev
  • 3,029
  • 9
  • 33
  • 31
18
votes
3 answers

Create a pivot table that lists out values

What aggfunc do I need to use to produce a list using a pivot table? I tried using str which doesn't quite work. Inputs import pandas as pd data = { 'Test point': [0, 1, 2, 0, 1], 'Experiment': [1, 2, 3, 4, 5] } df = pd.DataFrame(data) print…
bluprince13
  • 4,607
  • 12
  • 44
  • 91
18
votes
3 answers

Pandas Pivot Table List of Aggfunc

Pandas Pivot Table Dictionary of Agg function I am trying to calculate 3 aggregative functions during pivoting: Count Mean StDev This is the code: n_page = (pd.pivot_table(Main_DF, values='SPC_RAW_VALUE', …
Felix
  • 1,539
  • 8
  • 20
  • 35
17
votes
2 answers

Obsolete items in pivot table list

In a pivot table of mine, when I go to filter the data using the Row Label, where it shows the checkbox list where you can select one or many or all items to be included, this list includes items that no longer exist. Or alternatively, if you go to…
GeoffDS
  • 1,221
  • 5
  • 19
  • 31
17
votes
8 answers

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

Laravel Multiple Data Insert Error SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column 'unit_id' at row 2 (SQL: insert into product_prices (created_at, product_id, unit_id, updated_at) values (2016-12-06 06:56:01,…
Al-Amin
  • 748
  • 2
  • 13
  • 28
17
votes
1 answer

Python Pandas: pivot only certain columns in the DataFrame while keeping others

I am trying to re-arrange a DataFrame that I automatically read in from a json using Pandas. I've searched but have had no success. I have the following json (saved as a string for copy/paste convenience) with a bunch of json objects/dictionarys…
naja
  • 361
  • 1
  • 3
  • 10
17
votes
3 answers

Insert data to a pivot table in laravel

I have 3 tables: posts, tags, post_tag. Each Post has many tags so I use hasMany method for them. But when I choose for example 3 tags in my dropdown list, I can't add them to post_tag and as the result I can't select and show each post's tags. My…
saha
  • 221
  • 1
  • 5
  • 13
17
votes
2 answers

PivotTable to show values, not sum of values

I'm wanting to display a pivot table and for it to show me the actual values, one on each row, rather than a sum of the values. E.g. Name Jan Feb Mar Apr Bob 12 10 4 3 5 James 2 6 8 1 …
franglais
  • 928
  • 2
  • 15
  • 39
16
votes
3 answers

Pandas NaN introduced by pivot_table

I have a table containing some countries and their KPI from the world-banks API. this looks like . As you can see no nan values are present. However, I need to pivot this table to bring int into the right shape for analysis. A…
Georg Heiler
  • 16,916
  • 36
  • 162
  • 292
16
votes
7 answers

Rotate - Transposing a List> using LINQ C#

I'm having a List>, which is return from the remote data source (i.e., WCF). So, I need to modify the following data into a user-friendly list using LINQ The C# Code is List> PersonInfo = new List>() { new…
B.Balamanigandan
  • 4,713
  • 11
  • 68
  • 130
16
votes
2 answers

in R, customize names of columns created by dcast.data.table

I am new to reshape2 and data.table and trying to learn the syntax. I have a data.table that I want to cast from multiple rows per grouping variable(s) to one row per grouping variable(s). For simplicity, let's make it a table of customers, some of…
C8H10N4O2
  • 18,312
  • 8
  • 98
  • 134
16
votes
3 answers

Sort by "Grand Total" Column in Excel PivotTables?

As per an explanation found here by Mac CPub fro Excel 2011 (for OS X) supposedly you can sort "Grand Total" columns as per the following: "... Excel for Mac doesn't have a "Sort by Grand Total" option, but you can select the grand total column and…
ylluminate
  • 12,102
  • 17
  • 78
  • 152
16
votes
3 answers

Filtering pivot table columns, only count if

I was wondering if it's possible to filter a single pivot table column in excel. In other words, when you summarize the data by count, that the data for a certain column is only counted if it has a certain value. I know that it's possible to get…
andrew b
  • 205
  • 2
  • 3
  • 7
15
votes
1 answer

In OLAP cube wrong Grand Total when attribute is filtered

A user trying to check the Sales Amount per Salesperson. Sample data: Salesperson Sales Amount 001 1000 002 500 003 750 Grand Total: 2250 It looks fine, but we have the…
Infinity
  • 828
  • 4
  • 15
  • 41