grouping

d3 based multiple sub groups of a bar chart

孤街浪徒 提交于 2021-02-10 06:10:24
问题 I am trying to produce a bar graph that has multiple hierarchical / groupings of factors using d3.js . An example from excel of what I am attempting to create, subgrouped by Variety and Irrigation treatment: I have searched for quite some time and have yet to see an example of something like the example graph above. The closet I found is this (as well as this, this, and this). but they all lack the one more level of grouping that I need. Is there a way to create multiple groupings in d3.js ,

groupBy-like function such that the binary predicate holds between consecutive elements of each group instead of any two

为君一笑 提交于 2021-02-08 13:57:14
问题 On Hackage I see that groupBy's implementation is this: groupBy :: (a -> a -> Bool) -> [a] -> [[a]] groupBy _ [] = [] groupBy eq (x:xs) = (x:ys) : groupBy eq zs where (ys,zs) = span (eq x) xs which means that the preticate eq holds between any two elements of each group . Examples: > difference_eq_1 = ((==1).) . flip (-) > first_isnt_newline = ((/= '\n').) . const > > Data.List.groupBy difference_eq_1 ([1..10] ++ [11,13..21]) [[1,2],[3,4],[5,6],[7,8],[9,10],[11],[13],[15],[17],[19],[21]] > >

javascript object grouped by multiple attributes using js

我只是一个虾纸丫 提交于 2021-02-08 09:19:15
问题 Here is my JavaScript object. I want to have a method to dynamically generate an object grouped by one or more attributes. The parameter attrs is an array, which contains some attributes for grouping. var input= [ {fistname:'Joe', age:'10', sex:'boy', class:'3'}, {fistname:'Tom', age:'11', sex:'boy', class:'3'}, {fistname:'Amily', age:'10', sex:'girl', class:'3'}, {fistname:'Bob', age:'11', sex:'boy',class:'4'}, {fistname:'Susan', age:'12', sex:'girl', class:'4'} ] var attrs = ['age', 'class'

Can i partition a stream combining with the grouping by functionality?

我们两清 提交于 2021-02-08 08:56:19
问题 I am grouping and partioning a stream as follows: // Partioning Map<Boolean, List<Person>> partitioned = persons.stream(). collect(Collectors.partitioningBy(p -> p.getAge() > 20)); // Grouping Map<String, List<Person>> grouped = persons.stream() .collect(Collectors.groupingBy(p -> p.getCity())); Is there a way i can combine both of these? I tried combining both with using groupingBy inside partioningBy, but did not get the things right. Any suggestion? The expected result is the partition the

Create bins with awk histogram-like

浪子不回头ぞ 提交于 2021-02-08 07:51:17
问题 Here's my input file : 1.37987 1.21448 0.624999 1.28966 1.77084 1.088 1.41667 I would like to create bins of a size of my choice to get histogram-like output, e.g. something like this for 0.1 bins, starting from 0 : 0 0.1 0 ... 0.5 0.6 0 0.6 0.7 1 ... 1.0 1.1 1 1.1 1.2 0 1.2 1.3 2 1.3 1.4 1 ... My file is too big for R, so I'm looking for an awk solution (also open to anything else that I can understand, as I'm still a Linux beginner). This was sort of already answered in this post : awk

How to correctly use group_by() and summarise() in a For loop in R

百般思念 提交于 2021-02-07 13:34:55
问题 I'm trying to calculate some summary information to help me check for outliers in different groups in a dataset. I can get the sort of output I want using dplyr::group_by() and dplyr::summarise() - a dataframe with summary information for each group for a given variable. Something like this: Sepal.Length_outlier_check <- iris %>% dplyr::group_by(Species) %>% dplyr::summarise(min = min(Sepal.Length, na.rm = TRUE), max = max(Sepal.Length, na.rm = TRUE), median = median(Sepal.Length, na.rm =

Python pandas dataframe: find max for each unique values of an another column

倖福魔咒の 提交于 2021-02-07 12:51:22
问题 I have a large dataframe (from 500k to 1M rows) which contains for example these 3 numeric columns: ID, A, B I want to filter the results in order to obtain a table like the one in the image below, where, for each unique value of column id, i have the maximum and minimum value of A and B. How can i do? EDIT: i have updated the image below in order to be more clear: when i get the max or min from a column i need to get also the data associated to it of the others columns 回答1: Sample data (note

Groups of unique pairs where members appear once per group

大兔子大兔子 提交于 2021-02-07 06:36:23
问题 I have this code: from itertools import groupby from itertools import combinations teams = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] combo = list(combinations(teams, 2)) The output is a list of 45 tuples. [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (6, 7), (6, 8),

'Could not interpret input' error with Seaborn when plotting groupbys

眉间皱痕 提交于 2021-02-07 05:20:15
问题 Say I have this dataframe d = { 'Path' : ['abc', 'abc', 'ghi','ghi', 'jkl','jkl'], 'Detail' : ['foo', 'bar', 'bar','foo','foo','foo'], 'Program': ['prog1','prog1','prog1','prog2','prog3','prog3'], 'Value' : [30, 20, 10, 40, 40, 50], 'Field' : [50, 70, 10, 20, 30, 30] } df = DataFrame(d) df.set_index(['Path', 'Detail'], inplace=True) df Field Program Value Path Detail abc foo 50 prog1 30 bar 70 prog1 20 ghi bar 10 prog1 10 foo 20 prog2 40 jkl foo 30 prog3 40 foo 30 prog3 50 I can aggregate it

'Could not interpret input' error with Seaborn when plotting groupbys

对着背影说爱祢 提交于 2021-02-07 05:19:19
问题 Say I have this dataframe d = { 'Path' : ['abc', 'abc', 'ghi','ghi', 'jkl','jkl'], 'Detail' : ['foo', 'bar', 'bar','foo','foo','foo'], 'Program': ['prog1','prog1','prog1','prog2','prog3','prog3'], 'Value' : [30, 20, 10, 40, 40, 50], 'Field' : [50, 70, 10, 20, 30, 30] } df = DataFrame(d) df.set_index(['Path', 'Detail'], inplace=True) df Field Program Value Path Detail abc foo 50 prog1 30 bar 70 prog1 20 ghi bar 10 prog1 10 foo 20 prog2 40 jkl foo 30 prog3 40 foo 30 prog3 50 I can aggregate it