7,820 questions
1
vote
1
answer
56
views
Grouping landmak vectors by similarity (Python or R) - which is the simplest solution?
Pardon my verbosity but I think that I've much to explain. My English leaves something to desire. I'm 66 years old, from Italy, with some experience in programming, but I never ventured in the realm ...
0
votes
3
answers
83
views
Grouping rows of contract relationships
I have a table of relationships between contracts with two variables: ID1 (refinanced contract) and ID2 (refinancing contract). I want to create a variable that groups all rows of N to M refinancings. ...
4
votes
8
answers
292
views
How to extract a given number of ordered rows from a given number of randomly selected samples?
Starting with the example dat0 below, let's say I want to randomly extract 3 pairs of ìd`s.
Initial data (5 id pairs)
dat0 <-
structure(list(id = c("A", "A", "B", &...
1
vote
1
answer
183
views
In sequential order, find the first pair of results with a given relative change per group, in R
Consider this data:
group visit result rc10
<dbl> <dbl> <dbl> <dbl>
1 1 1 291 0
2 1 2 195 0
3 1 3 159 1
...
0
votes
1
answer
55
views
Calculating running total according to multiply groups in Power BI
I need to calculate the total number of piglets born per year and quarter, grouped by cycle. The cycle can range from 1 to 9. So I would like to see this: enter image description here There are some ...
-2
votes
2
answers
148
views
Split N people in X constrained groups with Google Sheets
[EDIT]
Hi everyone,
I am looking for clues to work out a sorting formula with Sheets.
We are planning "teambuilding" school trips at our international college. I need to split a list of 200+ ...
1
vote
1
answer
127
views
Most efficient identification and concise expression of a set of disjoint elements
I am attempting to determine how to most efficiently identify the sets consisting of the least number of terms for a group of disjoint sets.
I have a set of Boxes (B##) and Cartons (S##) which are ...
-2
votes
2
answers
95
views
Group an array of objects with a tolerance factor [closed]
I have an array of objects with a name and a value that looks like this (sorted by values):
var array = [
{ Name: "F", Value: 320 },
{ Name: "E", Value: 321 },
{ Name: ...
0
votes
1
answer
60
views
DB2/LUW - How to get group totals and sub-totals without a null label for the grand total?
I've read the answers for group totals with sub-totals. But none of them seem to address the issue of having a NULL label for the grand total. I tried both ROLLUP() and GROUPING SETS but they both ...
5
votes
3
answers
246
views
Efficiently group rows within tolerance for multiple numeric columns
I'm trying to group rows that have values within specific error/tolerance.
Input looks like this:
input <- data.frame(Row_number = 1:22,
Name = c(rep("A",6), rep("...
4
votes
0
answers
159
views
Is there a setting to omit "by" column(s) from result of data.table expression in R?
This is not a big problem, but just a little irritation.
when I do
DT[, .(<list of column expressions>), by = species];
the by column appears as the first result column.
Normally this is a GOOD ...
0
votes
1
answer
41
views
Group files whose names have embedded version numbers and process all but the latest versions
Preface:
This is a self-answered question, which is why there's no solution attempt in the question itself.
The task description is a focused reformulation of this now-deleted question.
I have a ...
2
votes
1
answer
123
views
how to group based on category in ggtree
I have a ggtree plot where I'm working with three different varieties for a plant, and since I'm planning to add additional info in the circos around it, I was wondering whether there is a simple way ...
0
votes
0
answers
109
views
I'm trying to group these shapes in CMU CS Academy, but I'm having trouble
class Objects:
page = 1
def __init__(self, x, y, fill, name):
self.x = x
self.y = y
self.fill = fill
self.name = name
def generateShelf(self):
...
-1
votes
3
answers
66
views
Oracle SQL staged grouping [closed]
Basically i have a big joined table with bunch of key columns (some of witch are calculated) and a value column:
key1
key2
key3
key4
value1
ABC
F
cat
1
10
ABC
F
cat
2
20
ABC
F
cat
2
10
ABC
F
dog
1
20
...
2
votes
3
answers
122
views
Group rows by group & overlapping time intervals & then keep highest priority row in R
I have a dataset as follows
data<- data.frame(group_ID= c("cred", "cred", "cred", "cyellow", "cyellow", "cgreen"),
...
0
votes
0
answers
65
views
ggtree add geom_cladelab based on sample's location
I finalized one version of a ggtree plot for a dataset of 300 samples, I made so based on the variety for this plant I colored the branches and tip labels (see figure below) .
However, I wish to add ...
1
vote
1
answer
92
views
Sum columns by ID in SQL
I am having trouble wrapping my head around the following problem. A sample dataset (truncated):
ID
Test
Instance
Weight
Outcome
1
A
1
0.5
2
1
A
1
0.5
2
1
A
1
0.5
2
1
A
1
0.5
2
1
A
1
0.5
2
1
A
1
0.5
2
...
2
votes
1
answer
78
views
openpyxl: (column) grouping - outline level not working & retaining only last one
I am trying to group columns at multiple levels and in this process only the last outline level is retained, though the outline number area in spreadhseet shows all outlines. I referred to this past ...
0
votes
1
answer
99
views
Sorting grouped individuals into defined spaces [closed]
Not sure if this is the right place get help with this kind of problem, but I am trying to solve this by coding so I'll try. If anyone knows about some better suited forum/place for this kind of ...
0
votes
1
answer
59
views
AVG function returns only 1 or 0, Apache Hive
Imagine I have a table with purchases, where I see id of customer, id of store where he bought something (I see other cols like prices, dates and others but not that important now). I have second ...
0
votes
0
answers
61
views
Odoo 16 advanced grouping in view
I'm trying to get extract information from Odoo surveys from the "Detailed answers" pivot view (I had to enable the pivot view myself since the detailed views only has tree and kanban views ...
1
vote
2
answers
79
views
How to create a gantt type chart for different element types that exist across different time periods, with a count of each type in each period
I wish to create a gantt type chart that will display the following data, grouped and counted. I have absolutely no idea how to approach this problem.
My data is like this - over 600 rows.
12,3,4,...
0
votes
1
answer
90
views
How to customize column names while grouping and aggregating?
I have a dataframe which has the following columns:
region_id, name, parent, parent_name, t2m, d2m, and tp.
I want to group and aggregate column values in a specific way. To enable that, I have ...
0
votes
3
answers
126
views
Group values of a flat array into sets of consecutive strings with the same leading characters
I have a dynamic array, each group of lines start with a specific code "S10.G00.00", "S10.G00.01", "S10.G00.02" ...
The array may be like this:
array:20 [▼
0 => &...
0
votes
1
answer
70
views
How can you change the line type and colour of the values inside a certain subgroup in R with treemapify?
I want to change the dividing lines of the values that are inside a certain subgroup in a treemap in R.
I will use a dataframe that's already been used in another question (different question):
name &...
0
votes
1
answer
74
views
calculate expanding average per group excluding current
Objective: Calculate the expanding mean of the 'valuation' column for each 'slug' group, excluding the current row's value (and respecting ordering i.e. 'week').
Example dataset (output is the desired ...
0
votes
4
answers
83
views
About sub-totals in Oracle SQL
I have a problem to get sub-totals for a specific query. Here is the schema I am working on :
drop table t;
create table t
(
instance number ,
id_sup number ,
id number ...
-1
votes
1
answer
39
views
Retrieve rows with max date only when duplicate when there is more than one column in the results
Retrieve rows with max date only when duplicate when there is more than one column in the results.
In this query, Receipts (RecNum, RecDate) duplicates. I only need the most recent receipt number.
My ...
0
votes
3
answers
131
views
Pandas value_counts with a little tolerance
I have a set of data and want to get its value_counts result:
df = pd.DataFrame(
[5.01, 5.01, 5.08, 6.1, 5.54, 6.3, 5.56, 5.55, 6.7],
columns=['val'])
>>> df
val
0 5.01
1 5.01
...
-2
votes
4
answers
198
views
How to iterate multidimensional array data and sum some values to return a grouped array
What's the simplest way and uses less computing power to check if a multidimensional array has some equal values in the sub keys and, if is in this way, make the sum of that?
Look at the input. It's ...
0
votes
2
answers
104
views
Running a sub-pipeline inside a group in mongodb
I have a bunch of event data which is identified by uid and timestamp. I have a number of aggregation pipelines which will calculate statistics for each user. These work if I run them one at a time, ...
0
votes
2
answers
52
views
Display WordPress posts in alternating sets of 3 then 2 items
I am struggling to get the following function work properly. I am trying to configure a loop inside WordPress with wrapping every first 3 items in a div. After that it should wrap the next 2 items in ...
0
votes
1
answer
88
views
Aggregate into custom groups
I'm not sure if this can be done in one stored procedure. I got it working using nested views but I want it to be as concise as possible.
Every time I try to select from a subquery, I get errors that ...
1
vote
2
answers
73
views
What is the problem with Group-Object sample?
What's wrong on me if I'm taking Microsoft's sample and it doesn't work?
The sample command and the expected result:
@(
@{ name = 'a' ; weight = 7 }
@{ name = 'b' ; weight = 1 }
@{ name = ...
0
votes
1
answer
95
views
Using JSONata to group by a property value
I would like to use JSONata to reformat a JSON response into a different structure grouped by values in the object. I've searched StackOverflow but cannot see an example that matches my needs. I ...
2
votes
3
answers
112
views
Calculate new column value based on max for group in Pandas Dataframe
I have dataframe containing list of subjects + dates of dispensing, one subject has more Dates of Dispensing and one single Date of dispensing for one subject can occur several times. Here is example:
...
0
votes
1
answer
200
views
Extract passing-bablok slopes and intercepts by group using mcreg (mcr package) in R
For about a hundred of different analytes (groups), I would like to compare serum and plasma values using passing-bablok regressions with the mcr::mcreg function, and extract slopes and intercepts (...
0
votes
2
answers
78
views
Group 2d array of dates and values by contiguous dates with the same value
I have a date range 2023-11-01 to 2024-01-04 and some date have different MinStay value.
This is my array of date range
$input = [
[ 'date' => '2023-11-01', 'MinStay' => 1 ],
[ 'date' => '...
1
vote
4
answers
360
views
Separating a Dataframe Column by Multiple Delimiters Into New Columns Using Pandas
I have a table similar to the one below where I have a summary column with groups and an associated value separated by a colon where each separate group with its value is separated by a comma. (group1:...
2
votes
3
answers
63
views
R - calculate value by each seperate instance of a variable in a data frame
I have a data frame with multiple instances of variables and their durations. I would like to combine each separate instance of each variable and calculate their duration.
I've provided an example and ...
0
votes
2
answers
64
views
Grouping numbers in Powershell
I have an Array of string. For example:
Array[0] = ‘4’
Array[1] = ‘7’
Array[2] = ‘8‘
Array[3] = ‘9‘
Array[4] = ‘10‘
Array[5] = ‘21‘
Array[6] = ‘25‘
Array[7] = ‘26‘
Array[8] = ‘27‘
How can I group the ...
1
vote
1
answer
64
views
How can I group by a single field in mongo?
Two part question
I would like to group records by a single field.
then retrieve user information
I would like to group by the REF_NotifierID field.
Here is the data.
[
{
"_id": "...
1
vote
1
answer
80
views
Powershell grouping files that created within n minutes
I'm aiming to merge video files that created by a dashcam.
While driving, the camera writes a new file at every n minutes. If n=3, 30 minutes of driving generates 10 files that "date created"...
1
vote
2
answers
109
views
Make color blocks with text using ggplot2
I have a cowplot like the following, with different ggplot2 plots inside.
plot_list <- list()
plot_list[["P1"]] <- ggplot2::ggplot(mtcars, ggplot2::aes(x = mpg, y = drat)) + ggplot2::...
0
votes
0
answers
45
views
Issues with setpgid and Terminal Control in a Custom Shell Implementation
I'm working on building a custom command line interpreter in C, and I'm running into issues with process group management and terminal control when executing commands. Below is the main code I'm using:...
1
vote
2
answers
80
views
In a long table for a longitudinal study, how to loop efficiently across a large number of individuals?
I work on sexually transmitted diseases, such as gonorrhoea, and their possible consequences, such as ectopic pregnancy in women. I have a first dataset (df_gono) that contains whether and how many ...
0
votes
1
answer
79
views
rolling average across grouped dates
I have a time series of half-hourly observations. I want a running average of the range of each day's measurements. I group by date and get the correct daily ranges, but then everything I can think ...
0
votes
2
answers
97
views
Reduce 2d array of change history to initial and final values per id and remove rows where no change
There is an array of "movements" of elements, about the same, only it can be many times more:
Array
(
[0] => Array
(
[id] => 90415
[oldDate] => ...
1
vote
1
answer
88
views
across() function using a calculation with a third variable
I have a website usage dataset with multiple variables, and each variable has its own log data. The clients in this dataset can interact with many different things on the website. For example, they ...