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

Pivot Table-like Output in R?

I am writing a report that requires the generation of a number of pivot tables in Excel. I would like to think there is a way to do this in R so that I can avoid Excel. I would like output like the screenshot below (teacher names redacted). As far…
Jeff Erickson
  • 3,783
  • 8
  • 36
  • 43
12
votes
1 answer

Render jquery datatable inside React-pivottable

I have implemented react-pivottable just wanted to know is there a way to display the entire data set in jQuery data table view i.e, I have a few columns want to display all of them in a tabular view for the following data below [ 'SRN',…
dhana lakshmi
  • 847
  • 1
  • 12
  • 29
12
votes
3 answers

Pandas change order of columns in pivot table

The representation of pivot tabel not looks like something I looking for, to be more specific the order of the resulting rows. I can`t figure out how to change it in proper way. Example df: test_df =…
cbccbd
  • 173
  • 1
  • 2
  • 9
12
votes
4 answers

Seed a pivot table using factories in Laravel

I'm new to Laravel and I'm looking for a good way to seed a pivot table using factories. I don't want to use plain seeders. I'll show you the case: I have three tables (users, skills, and user_skill). users user_skill …
alexhoma
  • 342
  • 1
  • 7
  • 19
12
votes
1 answer

Python Take first observation per group Using pandas.pivot_table

How can I specify a function in the aggfunc=[] using pandas.pivot_table so that I get the first observation of every group just like the result I get running groupby().first()?
Zhongjie Zhang
  • 123
  • 1
  • 1
  • 7
12
votes
3 answers

How to SUM parts of a column which have same text value in different column in the same row

I have a column with names and a column with numbers: FirstName Name Number John Smith 17 John Smith 26 Peter Smith 116 Peter Smith 25 Franck Black 17 Luke Peterson 17 Luke …
user2285265
  • 123
  • 1
  • 2
  • 7
12
votes
1 answer

Pivot table strings grouping under pivot column?

JOB ENAME -------- ---------- ANALYST SCOTT ANALYST FORD CLERK SMITH CLERK ADAMS CLERK MILLER CLERK JAMES MANAGER JONES MANAGER CLARK MANAGER BLAKE PRESIDENT KING SALESMAN ALLEN SALESMAN …
Vishwanath Dalvi
  • 35,388
  • 41
  • 123
  • 155
12
votes
3 answers

Recreate Source Data from PivotTable Cache

I am trying to extract the source data from a PivotTable that uses a PivotTable cache and place it into a blank spreadsheet. I tried the following but it returns an application-defined or object defined…
Kuyenda
  • 4,529
  • 11
  • 46
  • 64
12
votes
1 answer

Count occurrences of values

I have a column of text values with repeated values. I want to create a new column of unique values (no repeats) and a column with the frequency of each of those values. What's the easiest way to do that? Efficiency isn't much of a concern as it's…
sagacious
  • 129
  • 1
  • 1
  • 3
12
votes
3 answers

Pivot Calculated formula: SUM(Field1)/AVG(Field2)

I've a simple table with some amount and interval in sec by date and product name. Month | Product | Amount | Interval in sec ------------------------------------------ 05-'12| Prod A | 10 | 5 05-'12| Prod A | 3 | 5 05-'12| Prod B | 4 …
Bas
  • 597
  • 5
  • 10
  • 22
11
votes
3 answers

Adding total row to pandas DataFrame groupby

I am aware of this link but I didn't manage to solve my problem. I have this below DataFrame from pandas.DataFrame.groupby().sum(): Value Level Company Item 1 X …
user12392864
  • 288
  • 1
  • 3
  • 11
11
votes
1 answer

IndexError: index 1491188345 is out of bounds for axis 0 with size 1491089723

I have a dataframe,df with 646585 rows and 3 columns which looks like : index inp aco count 0 2.3.6. dp-ptp-a2f 22000 1 2.3.12. ft-ptp-a2f 21300 2 2.5.9. dp-ptp-a2f 21010 3 …
Bode
  • 527
  • 2
  • 9
  • 19
11
votes
3 answers

Pandas pivot_table preserve order

>>> df A B C D 0 foo one small 1 1 foo one large 2 2 foo one large 2 3 foo two small 3 4 foo two small 3 5 bar one large 4 6 bar one small 5 7 bar two small 6 8 bar two large 7 >>> table = pivot_table(df, values='D',…
Rahul Ranjan
  • 125
  • 1
  • 1
  • 5
11
votes
1 answer

Python pandas pivot from long to wide

My data is currently in a long format. Below is a sample: Stock Date Time Price Year AAA 2001-01-05 15:20:09 2.380 2001 AAA 2002-02-23 10:13:24 2.440 2002 AAA 2002-02-27 …
alexalexalex
  • 147
  • 2
  • 2
  • 7
11
votes
3 answers

Google spreadsheets: Insert pivot table in the active sheet.

My question is pretty much stated in the title. I have been trying to add a pivot table in the same sheet in which i have charts and other analysis done but when i try to add a pivot table it create a new sheet. I am trying to convert an Excel…
S.aad
  • 518
  • 1
  • 5
  • 22