group-by Questions
2
I have a dataframe with a MultiIndex.
01.01 02.01 03.01 04.01
bar total1 40 52 18 11
total2 36 85 5 92
baz total1 23 39 45 70
total2 50 49 51 65
foo total1 23 97 17 97
total2 64 56 94 45
qux to...
Ratliff asked 21/8, 2016 at 19:2
14
Solved
I have a data frame with three string columns. I know that the only one value in the 3rd column is valid for every combination of the first two. To clean the data I have to group by data frame by f...
5
Solved
How can I using group by with union in T-SQL? I want to group by the first column of a result of union, I wrote the following SQL but it doesn't work. I just don't know how to reference the specifi...
Cunnilingus asked 22/10, 2009 at 3:8
17
Solved
This is obviously simple, but as a numpy newbe I'm getting stuck.
I have a CSV file that contains 3 columns, the State, the Office ID, and the Sales for that office.
I want to calculate the percent...
7
Solved
I have a table with 3 columns which looks like this:
File User Rating (1-5)
------------------------------
00001 1 3
00002 1 4
00003 2 2
00004 3 5
00005 4 3
00005 3 2
00006 2 3
Etc.
I want to ge...
Lucania asked 1/6, 2011 at 20:28
6
Solved
I want to split the following dataframe based on column ZZ
df =
N0_YLDF ZZ MAT
0 6.286333 2 11.669069
1 6.317000 6 11.669069
2 6.324889 6 11.516454
3 6.320667 5 11.516454
4 6.325556 5 11.516...
4
Solved
I've written this code to find duplicates and it works fine:
SELECT *
FROM StyleTable
GROUP BY Color
HAVING count(*) > 1
The problem is, it's returning just one of the duplicate rows. Is it...
Landscapist asked 5/3, 2012 at 22:12
5
Solved
This query seems to work perfectly on my older machine. However, on my new machine with MySQL 5.7.14 and PHP 5.6.25 it throws the error:
Fatal error: Uncaught exception 'PDOException' with message...
2
Solved
It seems like there is no native function for that purpose in Presto SQL. Do you know any way to efficiently aggregate a group and return its median?
Arbutus asked 23/9, 2020 at 14:41
5
Solved
I have a list of my objects:
class MyObj
{
public String Title { get; set; }
public Decimal Price { get; set; }
public String OtherData { get; set; }
}
var list = new List<MyObj> {
new ...
Audient asked 25/5, 2011 at 11:7
13
This should be straightforward, but the closest thing I've found is this post:
pandas: Filling missing values within a group, and I still can't solve my problem....
Suppose I have the following dat...
Staple asked 13/11, 2013 at 22:43
2
Solved
I have the following columns in Table A which records users fingerprint "transaction" every time they check in or check out from a building.
CREATE TABLE user_transactions (
id serial PR...
Phenacite asked 20/12, 2011 at 16:10
7
Solved
This is my dataframe:
customer_name order_dates order_values
1 John 2010-11-01 15
2 Bob 2008-03-25 12
3 Alex 2009-11-15 5
4 John 2012-08-06 15
5 John 2015-05-07 20
Let's say I want to add an orde...
4
Solved
I have an array of object that have different values like
items=[{id:1,category:"cat_1" , title:"My title 1"},{id:2,category:"cat_2" , title:"My title 2"},{id:6,category:"cat_1" , title:"Another ...
Arsphenamine asked 24/3, 2018 at 7:0
11
Solved
I have a table named forms with the following structure-
GROUP | FORM | FILEPATH
====================================
SomeGroup | SomeForm1 | SomePath1
SomeGroup | SomeForm2 | SomePath2
----------...
Burgle asked 31/5, 2012 at 9:16
11
Solved
Suppose I want to calculate the proportion of different values within each group. For example, using the mtcars data, how do I calculate the relative frequency of number of gears by am (automatic/m...
9
Solved
The docs show how to apply multiple functions on a groupby object at a time using a dict with the output column names as the keys:
In [563]: grouped['D'].agg({'result1' : np.sum,
.....: 'result2' ...
Tambourine asked 25/1, 2013 at 20:26
5
Solved
I've been using PostgreSQL and now migrating to MySQL.
In my queries, I'm using PostgreSQL's SELECT DISTINCT ON (col1, col2, col3), I was wondering if there is any counterpart of this statement i...
Relativity asked 16/7, 2013 at 9:56
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
6
Solved
I have the following data frame in IPython, where each row is a single stock:
In [261]: bdata
Out[261]:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 21210 entries, 0 to 21209
Data colum...
5
I want to write a criteria query using "group by" and want to return all the columns.
Plane sql is like this:
select * from Tab group by client_name order by creation_time;
I understand that it...
Legitimist asked 21/12, 2012 at 21:52
4
Solved
I'm trying to create a duplicate row if the row meets a condition. In the table below, I created a cumulative count based on a groupby, then another calculation for the MAX of the groupby.
df['Pat...
Isobelisocheim asked 27/3, 2017 at 18:24
3
Solved
What is the most efficient way to use groupby and in parallel apply a filter in pandas?
Basically I am asking for the equivalent in SQL of
select *
...
group by col_name
having condition
I think t...
6
Solved
I am trying to create a new column 'ab_weighted' in a Pandas dataframe based on two columns 'a','b' in that dataframe grouped by 'c'.
Specifically, I am trying to replicate the output from this R c...
15
Solved
How do I count the number of records returned by a group by query,
For eg:
select count(*)
from temptable
group by column_1, column_2, column_3, column_4
Gives me,
1
1
2
I need to count th...
Abelmosk asked 28/2, 2011 at 20:6
© 2022 - 2024 — McMap. All rights reserved.