pivot-table Questions

1

Can we in SQL (preferably Postgresql) mimic the pandas function pivot_table? For example, let's say we have a table with the following 3 columns: Name Day Value John Sunday 6 John Monday 3 John...
Euphonious asked 16/11, 2021 at 17:28

5

Solved

I'm new to Laravel and 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). ...
Souvenir asked 2/10, 2016 at 16:33

7

Solved

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 PivotT...
Citizen asked 11/6, 2014 at 19:18

3

Solved

I have a table with stats for universities that looks like this: StatID | UniversityID | StatValue 1 | 1 | 100 2 | 1 | 90 3 | 1 | 80 1 | 2 | 50 2 | 2 | 55 I'd like a query to return something li...
Vice asked 18/2, 2012 at 3:59

6

Solved

I need to convert the Excel matrix FIRST in the table LATER: FIRST: P1 P2 P3 P4 F1 X F2 X X F3 X X F4 X X LATER: F P VALUE F1 P1 X F1 P2 F1 P3 F1 P4 F2 P1 X F2 P2 X F2 P3 F2 P4 F3 P1 F3 P2 X...
Busily asked 12/12, 2013 at 11:11

7

I have a question about how to pivot the table in MySQL. I have a dataset, columns like this: ID Name job_title 1 Sam Fireman 2 Tomas Driver 3 Peter Fireman 4 Lisa Analyst 5 Marcus Postman 6 Step...
Alcibiades asked 19/2, 2018 at 0:1

10

Solved

This code: df2 = ( pd.DataFrame({ 'X' : ['X1', 'X1', 'X1', 'X1'], 'Y' : ['Y2', 'Y1', 'Y1', 'Y1'], 'Z' : ['Z3', 'Z1', 'Z1', 'Z2'] }) ) g = df2.groupby('X') pd.pivot_table(g, values='X', rows=...
Mayweed asked 12/10, 2012 at 13:43

12

I am trying to produce a "reverse pivot" function. I have searched long and hard for such a function, but cannot find one that is already out there. I have a summary table with anywhere u...

3

I have this query that yields a total of 1 million rows similar to the example extract shown bellow SELECT * FROM sales shop date hour row_no amount shop_1 2012-08-14 00:08:00 P01 10 sho...
Purdah asked 21/4, 2017 at 14:4

4

Solved

I have a table with two columns: +---------+--------+ | keyword | color | +---------+--------+ | foo | red | | bar | yellow | | fobar | red | | baz | blue | | bazbaz | green | +---------+--------+ ...
Ballista asked 10/8, 2017 at 18:43

4

Solved

I have a dataframe as given: df = {'TYPE' : pd.Series(['Advisory','Advisory1','Advisory2','Advisory3']), 'CNTRY' : pd.Series(['IND','FRN','IND','FRN']), 'VALUE' : pd.Series([1., 2., 3., 4.])} d...
Xanthus asked 13/6, 2017 at 6:6

6

Solved

I have two models which are joined by a pivot table, User and Task. I have a user_id and a task_id. What is the neatest way to check whether a record exists for this combination of user and task?...
Sunk asked 9/2, 2016 at 7:8

4

Solved

Given the below dataframe, if rows are grouped by first name and last name, how can I find and create new rows for a group that does not have a row for every type in the types list. So in the examp...
Wolfie asked 3/12, 2023 at 3:50

1

I have created the following example Google Sheet to illustrate the question, https://docs.google.com/spreadsheets/d/1UIwxJe0Jww3cJYM9rpZUUI1Ppf7iSr-sOootuJJgWgQ/edit?usp=sharing You'll see that I ...
Burlie asked 10/11, 2023 at 2:34

4

Solved

I've got a large table of data in an Excel spreadsheet that, essentially, can be considered to be a collection of values for individuals identified as belonging to various subpopulations: IndivID...
Penguin asked 18/11, 2012 at 14:32

2

Solved

I have three tables, roles(id, name); users(id, email, password); user_role(id, user_id, role_id); In this scenario, I have users table is associated to roles table with many to many relation. ...
Neural asked 2/2, 2015 at 9:26

3

Solved

For a dataframe like this: d = {'id': [1,1,1,2,2], 'Month':[1,2,3,1,3],'Value':[12,23,15,45,34], 'Cost':[124,214,1234,1324,234]} df = pd.DataFrame(d) Cost Month Value id 0 124 1 12 1 1 214 2 2...
Mulcahy asked 22/10, 2015 at 20:42

5

Both pandas' crosstab and pivot_table functions seem to provide the exact same functionality. Are there any differences?
Milreis asked 28/3, 2016 at 17:44

7

I'm building an application using Laravel 4.2. I have a model for units and another for users and pivot table user_units. Every user in this application can select a unit and add it to his favorite...
Mcwherter asked 21/11, 2014 at 15:37

5

I am using C# winforms to create an application that needs to turn a datatable into a pivot table. I have the pivot table working fine from a SQL end, but creating it from a datatable seems trickie...
Miry asked 2/4, 2012 at 17:43

0

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=&qu...
Kirimia asked 25/5, 2023 at 10:35

2

Is there a better way to create a contingency table in pandas with pd.crosstab() or pd.pivot_table() to generate counts and percentages. Current solution cat=['A','B','B','A','B','B','A','A','B'...
Eleanoreleanora asked 16/3, 2016 at 18:53

1

Solved

How do I transpose and transform this table: Receipt date Amount Child 1 Shirt size Age Child 2 Shirt size Age Child 3 Shirt size Age 5/1/2023 $39.00 John S 11-12 Mary L 14 Peter S 9 5/5/...

3

Solved

I have the following code, which takes the values in one column of a pandas dataframe and makes them the columns of a new data frame. The values in the first column of the dataframe become the inde...
Sienna asked 4/3, 2014 at 13:41

2

Solved

I have a pandas dataframe: Col X Col Y class 1 cat 1 class 2 cat 1 class 3 cat 2 class 2 cat 3 that I want to transform into: cat 1 cat 2 cat 3 class 1 1 0 0 class 2 1 0 1 class 3 0 1 0 where t...
Firebird asked 6/6, 2015 at 5:56

© 2022 - 2024 — McMap. All rights reserved.