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
1
vote
1 answer

Calculating multiple colors and duplicate colors in a pivot table in pandas

I have a DataFrame df that contains information about orders, including the 'Webshop_Order', 'Category', 'Level', 'Class', 'USIM', 'Size', 'Color', 'Length', 'Demand_Qty', and 'Return_Qty' columns. I want to create a pivot table that includes the…
sdave
  • 531
  • 4
  • 18
1
vote
1 answer

How to convert duplicated data to transposed data

I create a dataset with 2 columns, there are names in column 1 and name data is duplicate itself. Column 2 contain different scores of names. I want to convert data like screenshoot. Is there any way to do it? I tried creating a pivot table from…
1
vote
2 answers

Summary pivot table from matrix data

I have an excel file that contains a table formatted in this way (the example here below is just notional): Table 1 Column A Column B Column C Group A Option 12 Option 33 Group B Option 11 Option 15 Group B Option 12 Option 13 Group…
FancyPants
  • 73
  • 1
  • 6
1
vote
1 answer

How use crosstab with apply or sapply function

I am struggling with using the crosstab function, available at the link: source("http://pcwww.liv.ac.uk/~william/R/crosstab.r") I have also used the gtsummary library and converted mtcars to a tibble, then converted the vs and am columns to…
12666727b9
  • 1,133
  • 1
  • 8
  • 22
1
vote
0 answers

Pivot dataframe in dash table

I have a dataframe with many rows and many columns. I made a pivot with this command: dati_prev_pivot=pd.pivot(ap_dati_tabella,columns=['prog_anno'],index=['int_id_ait','int_desc'],values=['tariffa'] so the dataframe is re-shaped like…
1
vote
0 answers

How do I get my slicer to automatically update based on a data validation dropdown selection?

I wrote some code below to have my pivot table's filters (in the slicer) update when a data validation dropdown is changed. So far, this is what I have but it is not working: Option Explicit ' sheet module Private Sub Worksheet_Change(ByVal Target…
Matt
  • 11
  • 1
1
vote
1 answer

PostgreSQL - How to use Crosstab request

I have a lulc table with a lulc column which looks like that: select distinct lulc.lulc from lulc lulc Transport - Roads Transport - Other Green space - Forest Urban Fabric - Low - Non Res Urban Fabric - High - NonRes Open…
Sof
  • 23
  • 5
1
vote
0 answers

Pivot Table in Python - Making column values into columns and ordering the columns in a specific way

I have a subset of a dataframe (actual dataframe is a lot larger with over 3000 rows) in Python such that df <- data.frame(Name= c["John", "Karla", "Sandy", "John", "John", "Sandy"], Course Title = c["Training 2", "Training", "Training 2",…
Donut
  • 11
  • 4
1
vote
2 answers

Accessing 'upper level name' of pandas multi-index

I'm trying to learn how to use Pandas crosstab functionality but I can't find way to access 'upper level name' of multi-index dataframe that crosstab produces. Simple example: df_test = pd.DataFrame.from_dict({'A': [1, 2, 3], 'B': [4, 5, 6]},…
Ville
  • 57
  • 9
1
vote
1 answer

Pivot unclear grouping / remove result rows

I am having issues to understand the pivot table in POI I could generate a compact pivot, but I have still issues to identify how to remove the result rows (red marked) how are these rows named? So maybe I could have found them by searching for…
cilap
  • 2,215
  • 1
  • 25
  • 51
1
vote
1 answer

Is there a way to manipulate pandas pivot table to obtain a specific format of output?

i got this pivot table result my pivot table code looks like this: result = pd.pivot_table(excel, values=["Percent"], columns='Date', index='items', aggfunc={"Percent":np.mean}) but i need to looks like this: Anyone knows how i can get it? i…
MarcelGlez
  • 11
  • 2
1
vote
1 answer

How to create a matrix in Excel?

I have some data that looks a bit like this: Value_1 Value_2 Value_3 TRUE TRUE FALSE TRUE TRUE FALSE TRUE FALSE TRUE I want to create a matrix which counts the number of times each combination of two values are flagged as true on the…
SRJCoding
  • 335
  • 2
  • 15
1
vote
1 answer

Why is SQL Server Pivot being case sensitive on TabTypeId instead of treating it as the actual column name?

In T-Sql I am parsing JSON and using PIVOT. Select * from (select [key],convert(varchar,[value])[value] from openjson ('{"Name":"tew","TabTypeId":9,"Type":3}'))A pivot(max(value) for [key] in ([Name],tabTypeId,[Type]))b It is not treating…
Narendra
  • 11
  • 5
1
vote
2 answers

Create contingency table and appropriate plot with conditional data from data frame in R

I have a data frame called df containing 490 cases and 3 variables (V1, V2, and V3). That is 490 x 3. Each observation is either 1, 2, or NA (there are also some missing values). With the commands expss::val_lab() and expss::num_lab(), value 1 has…
pdeli
  • 436
  • 3
  • 13
1
vote
0 answers

How to merge empty cells in a pivot table using python

Ive a pivot table like this : table = pd.pivot_table( df, values="D", index=["A", "B"], columns=["C"], aggfunc=np.sum, margins=True, margins_name="total", …