unique

Remove elements from one array if present in another array, keep duplicates - NumPy / Python

a 夏天 提交于 2020-06-21 19:07:33
问题 I have two arrays A (len of 3.8million) and B (len of 20k). For the minimal example, lets take this case: A = np.array([1,1,2,3,3,3,4,5,6,7,8,8]) B = np.array([1,2,8]) Now I want the resulting array to be: C = np.array([3,3,3,4,5,6,7]) i.e. if any value in B is found in A , remove it from A , if not keep it. I would like to know if there is any way to do it without a for loop because it is a lengthy array and so it takes long time to loop. 回答1: Using searchsorted With sorted B , we can use

Excel - Count unique values that meets multiple criteria

◇◆丶佛笑我妖孽 提交于 2020-06-13 06:01:25
问题 I have 5 columns: Quarter, Item, Type, Count, Date I am trying to pull a UNIQUE count of date for each Quarter & Item combination ie. FY20Q3-AU has 2 different dates, FW20Q3-GLW has 1 unique date, FY20Q3-GLE also has only 1 unique date Does anyone have any idea how I can accomplish this? I have been trying for a few hours modifying formulas that I found online without success. If possible, I am trying to do this without an array formula (not sure if that is even possible) I have tried: {=SUM(

R unique columns or rows incomparables with NA

六月ゝ 毕业季﹏ 提交于 2020-05-26 04:02:10
问题 Anyone know if the incomparables argument of unique() or duplicated() has ever been implemented beyond incomparables=FALSE ? Maybe I don't understand how it is supposed to work... Anyway I'm looking for a slick solution to keep only unique columns (or rows) that are identical to another column besides extra NA s? I can brute force it using cor() for example, but for tens of thousands of columns, this is intractable. Heres an example, sorry if its a little messy, but I think it illustrates the

R unique columns or rows incomparables with NA

為{幸葍}努か 提交于 2020-05-26 04:00:23
问题 Anyone know if the incomparables argument of unique() or duplicated() has ever been implemented beyond incomparables=FALSE ? Maybe I don't understand how it is supposed to work... Anyway I'm looking for a slick solution to keep only unique columns (or rows) that are identical to another column besides extra NA s? I can brute force it using cor() for example, but for tens of thousands of columns, this is intractable. Heres an example, sorry if its a little messy, but I think it illustrates the

Convert a data.frame into a list of characters based on one of the column of the dataframe with R

江枫思渺然 提交于 2020-05-15 08:09:12
问题 I need to convert a data.frame into a list of characters based on one of the column of the dataframe. Starting from a data.frame of two colums, the first one contains uniques values of compounds names, while the other contains compound type categories, that are not unique. Example: Compound_name Compound_type A Inhibitor_A B Inhibitor_B C Inhibitor_A D Inhibitor_C E Inhibitor_B I would like to end with a list based on the compound types that looks like this: Inhibitor_A 'A' 'C' Inhibitor_B 'B

Convert a data.frame into a list of characters based on one of the column of the dataframe with R

孤者浪人 提交于 2020-05-15 08:06:10
问题 I need to convert a data.frame into a list of characters based on one of the column of the dataframe. Starting from a data.frame of two colums, the first one contains uniques values of compounds names, while the other contains compound type categories, that are not unique. Example: Compound_name Compound_type A Inhibitor_A B Inhibitor_B C Inhibitor_A D Inhibitor_C E Inhibitor_B I would like to end with a list based on the compound types that looks like this: Inhibitor_A 'A' 'C' Inhibitor_B 'B

c++: ensure enum values are unique at compile time

怎甘沉沦 提交于 2020-05-13 05:25:23
问题 I have the following enum that describes error codes: typedef enum { et_general = 0, et_INVALID_CLI_FLAG = 1, ... et_undef = 500 } EErrorType; The main reason why I explicitly write the enum values, is to ease the debug process. Anyways, I wonder if there's a way, to make the compiler complain about non unique values . I can always check it at run time easily, but I'd like to avoid that. I've read this post and reviewed this answer. As I understand, that answer suggests to generate the enum

Get unique values from pandas series of lists

£可爱£侵袭症+ 提交于 2020-05-10 03:14:01
问题 I have a column in DataFrame containing list of categories. For example: 0 [Pizza] 1 [Mexican, Bars, Nightlife] 2 [American, New, Barbeque] 3 [Thai] 4 [Desserts, Asian, Fusion, Mexican, Hawaiian, F... 6 [Thai, Barbeque] 7 [Asian, Fusion, Korean, Mexican] 8 [Barbeque, Bars, Pubs, American, Traditional, ... 9 [Diners, Burgers, Breakfast, Brunch] 11 [Pakistani, Halal, Indian] I am attempting to do two things: 1) Get unique categories - My approach is have a empty set, iterate through series and

Get unique values from pandas series of lists

非 Y 不嫁゛ 提交于 2020-05-10 03:09:26
问题 I have a column in DataFrame containing list of categories. For example: 0 [Pizza] 1 [Mexican, Bars, Nightlife] 2 [American, New, Barbeque] 3 [Thai] 4 [Desserts, Asian, Fusion, Mexican, Hawaiian, F... 6 [Thai, Barbeque] 7 [Asian, Fusion, Korean, Mexican] 8 [Barbeque, Bars, Pubs, American, Traditional, ... 9 [Diners, Burgers, Breakfast, Brunch] 11 [Pakistani, Halal, Indian] I am attempting to do two things: 1) Get unique categories - My approach is have a empty set, iterate through series and

Retrieve Unique Values and Counts For Each

微笑、不失礼 提交于 2020-05-09 20:44:11
问题 Is there a simple way to retrieve a list of all unique values in a column, along with how many times that value appeared? Example dataset: A A A B B C ... Would return: A | 3 B | 2 C | 1 回答1: Use GROUP BY: select value, count(*) from table group by value Use HAVING to further reduce the results, e.g. only values that occur more than 3 times: select value, count(*) from table group by value having count(*) > 3 回答2: SELECT id,COUNT(*) FROM file GROUP BY id 来源: https://stackoverflow.com