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
11
votes
4 answers

How do I prevent a PivotChart from becoming a regular chart on sheet copy?

Using Excel 2010, I have written some VBA to copy selected sheets from a Master workbook to a Client workbook. The code works just fine to copy the data sheet which has data & PivotTable(s) associated with the data, and the chart sheet with one or…
FreeMan
  • 5,660
  • 1
  • 27
  • 53
11
votes
4 answers

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

I have a pivot table that connects users to workspaces. On the pivot table, I also have a column for role, which defines the users role for that workspace. Can I provide Accessor (Getter) & Mutator (Setter) methods on the role inside the pivot…
ATLChris
  • 3,198
  • 7
  • 39
  • 65
11
votes
2 answers

pandas - pivot_table with non-numeric values? (DataError: No numeric types to aggregate)

I'm trying to do a pivot of a table containing strings as results. import pandas as pd df1 = pd.DataFrame({'index' : range(8), 'variable1' : ["A","A","B","B","A","B","B","A"], 'variable2' : ["a","b","a","b","a","b","a","b"], 'variable3' :…
Paweł Rumian
  • 3,676
  • 3
  • 21
  • 27
11
votes
1 answer

How to use two different functions within crosstab/pivot_table in pandas?

Using pandas, is it possible to compute a single cross-tabulation (or pivot table) containing values calculated from two different functions? import pandas as pd import numpy as np c1 = np.repeat(['a','b'], [50, 50], axis=0) c2 = list('xy'*50) c3 =…
HappyPy
  • 9,839
  • 13
  • 46
  • 68
11
votes
1 answer

How can I use VBA to add a Connection (to an External Data Source) in Excel and Save it to that Excel spreadsheet's list of Connections

I can use VBA to create a new ADODB.Connection and associated ADODB.Command and ADOBD.Parameter and then create a PivotCache and a PivotTable Sub CreatePivotTable() 'Declare variables Dim objMyConn As ADODB.Connection Dim objMyCmd As…
Sam
  • 2,663
  • 10
  • 41
  • 60
11
votes
4 answers

Use formula in custom calculated field in Pivot Table

In Excel Pivot table report there is possibility for user intervention by inserting "Calculated Field" so that user can further manipulate the report. This seems like best approach compared to using formula on Pivot table data, outside the Pivot…
theta
  • 24,593
  • 37
  • 119
  • 159
11
votes
5 answers

refresh both the External data source and pivot tables together within a time schedule

In my last post Auto refresh pivottables data in excel on first run, i found that on my first execution the query from the External data source is refreshed and takes approximately 1 min to execute. and in my second run, the pivot tables are…
user42995
  • 335
  • 1
  • 5
  • 15
11
votes
10 answers

Ordering issue with date values when creating pivot tables

I have a 2-column spreadsheet which contains Dates and Sales figures as follows: When doing Right click -> Format Cells the values in the Dates column properly appear as Date (in the M/D/YYYY format). This applies to all the Dates cells with the…
Max
  • 12,794
  • 30
  • 90
  • 142
11
votes
6 answers

Refresh Pivot Table with Apache POI

I'm currently working on a Java application that uses a template excel file that contains a pivot table. The template file also has a data sheet that seeds the pivot table. This data sheet is dynamically loaded in the java application through the…
B Jammin
  • 281
  • 1
  • 3
  • 7
10
votes
2 answers

Java Crosstab - preparedstatement query

I have a typical crosstab query with static parameters. It works fine with createStatement. I want to use preparestatement to query instead. String query = "SELECT * FROM crosstab( 'SELECT rowid, a_name, value FROM test WHERE a_name =…
blue01
  • 2,035
  • 2
  • 23
  • 38
10
votes
2 answers

pandas pivot_table : NoneType object is not callable

after execute : df =pd.pivot_table(data_frame, values='volume', index=['marque'], columns=['canaux_vn_argus','annee'], aggfunc=np.sum, fill_value=0) I have this Exception: 'NoneType' object is not callable I use: Python 3.10.0 Pandas 1.4.0
m-zemmouri
  • 123
  • 8
10
votes
1 answer

How to use Dask Pivot_table?

I'm Trying to use Pivot_table on Dask with the following dataframe: date store_nbr item_nbr unit_sales year month 0 2013-01-01 25 103665 7.0 2013 1 1 2013-01-01 25 105574 1.0 2013 …
ambigus9
  • 1,417
  • 3
  • 19
  • 37
10
votes
1 answer

Pandas performance: pivot_table vs groupby

I am struggling with performance of pivot_table versus groupby On one hand I have: %time df.groupby(['INDEX', 'COLUMN']).agg({'VALUE':['sum','size']}).unstack(level='COLUMN') CPU times: user 2.28 s, sys: 29.8 ms, total: 2.31 s Wall time: 2.36 s On…
snovik
  • 1,027
  • 10
  • 14
10
votes
2 answers

Pivot table subtotals in Pandas

I have the following data: Employee Account Currency Amount Location Test 2 Basic USD 3000 Airport Test 2 Net USD 2000 Airport Test 1 Basic USD 4000 Town Test 1 Net USD …
Tony
  • 103
  • 1
  • 1
  • 4
10
votes
3 answers

Set a Column in Pivot Table as Percentage of Another

How can make a column to be a percentage of another column in pivot table? For example, in the following. I want set the second column as the following percentages 1/1, 44/46, 459/465 etc. For the third column, I want it to appear as the percentages…
Concerned_Citizen
  • 6,548
  • 18
  • 57
  • 75