unique

Delete unique elements from a list

陌路散爱 提交于 2019-12-17 19:30:31
问题 I faced some problem with solving the next problem: We have a list of elements (integers), and we should return a list consisting of only the non-unique elements in this list. Without changing order of the list I think the best way is to delete or remove all unique element. Take note that I just start to learn python and would like only the simplest solutions. Here is my code: def checkio(data): for i in data: if data.count(i) == 1: #if element seen in the list just ones, we delet this el ind

How to eliminate the extra minus sign when rounding negative numbers towards zero in numpy?

核能气质少年 提交于 2019-12-17 19:14:55
问题 I have a simple question about the fix and floor functions in numpy . When rounding negative numbers that are larger than -1 towards zero, numpy round them off correctly to zero however leaves a negative sign. This negative sign interferes with my costume unique_rows function since it uses the ascontiguousarray to compare elements of the array and this sign disturbs the uniqueness. Both round and fix behave the same in this regard. >>> np.fix(-1e-6) Out[1]: array(-0.0) >>> np.round(-1e-6) Out

Find index where elements change value numpy

纵然是瞬间 提交于 2019-12-17 18:16:04
问题 Suppose I have >>> v array([1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 3, 4, 3, 4, 3, 4, 5, 5, 5]) Is there an efficient numpy way to find each index where the value changes? For instance, I would want some result like, >>> index_of_changed_values(v) [0, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16] If this is not possible with some numpy routine, what is a fast way to do it in python? It would also be useful to me to be referred to some good numpy tutorials since I am a numpy beginner. 回答1: You can get this

Unique Folder Identifier

余生长醉 提交于 2019-12-17 16:53:29
问题 Earlier today someone generously answered my question regarding the retrieval of a unique identifier associated with files on the computer. Unique File Identifier The solution worked great, however, it does not address unique identifiers for folders. How can I retrieve a UID for specified directories, UID's that will stay with the directory through renames and moves. Update: FSCTL_GET_OBJECT_ID seems like it is the function I am after, but would someone be able to provide brief context on the

Creating a unique alphanumeric 10-character string

隐身守侯 提交于 2019-12-17 16:39:07
问题 I'm looking to create a simple short-lived reservation system, and I'd like to generate confirmation numbers that are unique random-looking alphanumeric short-ish, at least much shorter than 32 character-long strings returned by sha1 I'm only looking to have ~500 reservations, so I don't imagine high likelyhood of collissions. One idea I had is generate an sha1 hash based on a date-time stamp and username, then truncating it to its first 10 characters. Would something like that be reliably

upload images through php using unique file names

梦想与她 提交于 2019-12-17 16:37:15
问题 I am currently in the process of writing a mobile app with the help of phonegap. One of the few features that I would like this app to have is the ability to capture an image and upload it to a remote server... I currently have the image capturing and uploading/emailing portion working fine with a compiled apk... but in my php, I am currently naming the images "image[insert random number from 10 to 20]... The problem here is that the numbers can be repeated and the images can be overwritten..

How can I do SELECT UNIQUE with LINQ?

寵の児 提交于 2019-12-17 15:54:07
问题 I have a list like this: Red Red Brown Yellow Green Green Brown Red Orange I am trying to do a SELECT UNIQUE with LINQ, i.e. I want Red Brown Yellow Green Orange var uniqueColors = from dbo in database.MainTable where dbo.Property == true select dbo.Color.Name; I then changed this to var uniqueColors = from dbo in database.MainTable where dbo.Property == true select dbo.Color.Name.Distinct(); with no success. The first select gets ALL the colors, so how do I modify it to only get the unique

How to output duplicated rows

廉价感情. 提交于 2019-12-17 14:58:15
问题 I have the following data: x1 x2 x3 x4 34 14 45 53 2 8 18 17 34 14 45 20 19 78 21 48 2 8 18 5 In rows 1 and 3; and 2 and 5 the values for columns X1;X2,X3 are equal. How can I output only those 4 rows, with equal numbers? The output should be in the following format: x1 x2 x3 x4 34 14 45 53 34 14 45 20 2 8 18 17 2 8 18 5 Please, ask me questions if something unclear. ADDITIONAL QUESTION: in the output x1 x2 x3 x4 34 14 45 53 34 14 45 20 2 8 18 17 2 8 18 5 find the sum of values in last column

removing duplicates from array in objective c

我是研究僧i 提交于 2019-12-17 11:44:12
问题 I have an array with custom objects. Each array item has a field named "name". Now I want to remove duplicate entries based on this name value. How should I go about achieving this. Thanks in advance. 回答1: You might have to actually write this filtering method yourself: @interface NSArray (CustomFiltering) @end @implementation NSArray (CustomFiltering) - (NSArray *) filterObjectsByKey:(NSString *) key { NSMutableSet *tempValues = [[NSMutableSet alloc] init]; NSMutableArray *ret =

Javascript array sort and unique

折月煮酒 提交于 2019-12-17 10:23:55
问题 I have a JavaScript array like this: var myData=['237','124','255','124','366','255']; I need the array elements to be unique and sorted: myData[0]='124'; myData[1]='237'; myData[2]='255'; myData[3]='366'; Even though the members of array look like integers , they're not integers , since I have already converted each to be string: var myData[0]=num.toString(); //...and so on. Is there any way to do all of these tasks in JavaScript? 回答1: This is actually very simple. It is much easier to find