crosstab Questions
3
I have a crosstab function that I've used successfully many times in the past, but now it's dumping all the data at the end instead of pivoting it into the output table. It can't seem to find Cross...
Cardinalate asked 18/3, 2019 at 21:26
2
Solved
I have a sample table named antest as shown below to test the crosstab function.
create table antest(student text, subject text, result numeric);
insert into antest(student, subject, result) value...
Cuirbouilli asked 13/11, 2017 at 20:54
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
5
Solved
I have a dataset that looks something like this:
I'd like to aggregate all co values on one row, so the final result looks something like:
Seems pretty easy, right? Just write a query using c...
Respirator asked 11/5, 2018 at 19:54
2
I have a pyspark dataframe as follows in the picture:
I.e. i have four columns: year, word, count, frequency. The year is from 2000 to 2015.
I could like to have some operation on the (pyspar...
3
I'm using Python 3.4.1 with numpy 0.10.1 and pandas 0.17.0. I have a large dataframe that lists species and gender of individual animals. It's a real-world dataset and there are, inevitably, missin...
2
Solved
I have a view that produces the following resultset:
CREATE TABLE foo
AS
SELECT client_id, asset_type, current_value, future_value
FROM ( VALUES
( 1, 0, 10 , 20 ),
( 1, 1, 5 , 10 ),
( 1, 2, 7...
Yamada asked 4/5, 2015 at 13:27
2
Solved
I was wondering if there a way, in a SELECT statement on Postgres, to alias a column with the value of another column in the same data set.
Given this table:
id
key
value
1
a
d
2
a
e
3
...
Alien asked 29/7, 2021 at 15:51
3
Solved
I would like to count the number of all possible pairwise relations through a column (Value) based on another column (ID).
Example dataframe:
ID Value
0 1 A
1 1 A
2 1 A
3 1 B
4 1 C
5 2 B
6 2 C
7 2...
3
Solved
I have a table named as Product:
create table product (
ProductNumber varchar(10),
ProductName varchar(10),
SalesQuantity int,
Salescountry varchar(10)
);
Sample values:
insert into produc...
Gorblimey asked 22/1, 2015 at 11:41
5
Solved
I want my query result to look like this:
Person1 Person2 Person3 Person4 Total
Status1 2 4 7 3 16
Status2 0 1 0 3 4
Status3 0 0 0 0 0
Status4 0 1 3 0 4
Total 2 6 10 6 24
I'm able to get every...
3
Solved
I have a table like this
INPUT
id author size file_ext
--------------------------------
1 a 13661 python
1 a 13513 cpp
1 a 1211 non-code
2 b 1019 python
2 b 6881 cpp
2 b 1525 python
2 b 1208 non-...
Afreet asked 7/2, 2020 at 20:58
3
Solved
I am a beginner with pandas at best and I couldn't find a solution to this problem anywhere.
Let's say I have two variables: variable1, variable2.
They can have the following predefined values:
...
Avron asked 27/10, 2016 at 9:7
3
Solved
I've been doing a bit of research on this topic and I can't seem either find a workable solution, or one that is explained well enough for me to implement.
If you've ever created a crosstab query ...
Awaken asked 13/12, 2012 at 14:50
1
Solved
I am trying to create a crosstab table that will have rows = months and columns = days (ie 1, 2, 3, 4...31).
Month | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 ...
------+------+------+---...
Conover asked 24/9, 2018 at 20:23
1
I create a large query as a Common Table Expression - month_index using WITH clause. Is it possible to refer this Common Table Expression in a crosstab query's source sql?
When I did gets an erro...
Ovoid asked 12/8, 2015 at 17:19
3
Solved
I have a dictionary comprised of product names and unique customer emails who have purchased those items that looks like this:
customer_emails = {
'Backpack':['[email protected]','[email ...
Improbity asked 14/5, 2018 at 17:19
7
In SPSS, it is (relatively) easy to create a cross tab with multiple variables using the factors (or values) as the table heading. So, something like the following (made up data, etc.). Q1, Q2, and...
Monadelphous asked 19/3, 2010 at 18:28
4
Solved
I'm trying to write a script that copies data from a crosstab query to a .csv file in Postgres 8.4. I am able to run the command in the psql command line but when I put the command in a file and ru...
Fokine asked 14/4, 2015 at 16:32
3
Postgres 9.2.1 on OSX 10.9.2.
If I run the following crosstab example query:
CREATE EXTENSION tablefunc;
CREATE TABLE ct(id SERIAL, rowid TEXT, attribute TEXT, value TEXT);
INSERT INTO ct(rowid...
Humpy asked 15/4, 2014 at 1:16
2
Solved
I have a data source that is composed of object { groupName, rowName, colName, value }. I'm trying to put the fields row,col,val in a crosstab, separated by group [the group has headers]. A collect...
Leathern asked 4/4, 2011 at 20:9
5
I try to get result from this query
$sql = "
SET @col = NULL;
SET @sql = NULL;
Select
Group_Concat(Distinct
Concat(
'SUM(CASE WHEN tbl.sdate = ''',
colname,
''' THEN tbl.result ELSE NULL ...
1
I have seen that there are quit a few similar questions like this one, but I havent understood how to code it myself. Please have in mind that I am just a beginner in this field.
Basically I want ...
Postrider asked 29/9, 2016 at 20:47
2
Solved
I implemented this function in my Postgres database: http://www.cureffi.org/2013/03/19/automatically-creating-pivot-table-column-names-in-postgresql/
Here's the function:
create or replace functi...
Histaminase asked 22/4, 2016 at 22:57
3
Solved
I'm trying to sort my dynamic columns in a cross tab according to some custom scheme.
In the docs I found mention of comparatorExpression: Crosstab group bucket comparator expression. The result ...
Distinguishing asked 22/2, 2010 at 22:29
1 Next >
© 2022 - 2025 — McMap. All rights reserved.