duplicates

Transposing rows into columns based on a condition sql

a 夏天 提交于 2020-01-24 00:42:13
问题 I have a following table (a simplified example, in fact the table contains multiple IDs, with variable numbers of dates, and variable number of events for each date): IDs Date Event 102 1996-10-16 00:00:00 A 102 1996-10-23 00:00:00 A 102 1996-10-23 00:00:00 B 102 1997-01-14 00:00:00 A 103 1997-01-14 00:00:00 D 103 1997-01-15 00:00:00 A 103 1997-01-16 00:00:00 A 103 1997-01-16 00:00:00 B 103 1997-01-16 00:00:00 C I am trying to get a table where I will have distinct IDs/Date pairs, with the

LINQ checking for duplicate objects (excluding ID)

扶醉桌前 提交于 2020-01-23 18:45:49
问题 I am using LINQ to SQL (SQL Server) with C#. I have a table called "Cars" which automatically becomes the LINQ class/object called "Car". All well and good. Each car has a number of fields, say CarID(primary key int), EngineID, ColourID. I have 10 existing rows in the Cars table. Using all the cool LINQ stuff, I create a new "Car" object in C# with an overloaded constructor that I've created in my "Car" partial class. So for example: Car MyCar = new Car(17, 5); Now this nicely gives me a

Python Pandas - merge rows if some values are blank

限于喜欢 提交于 2020-01-23 01:43:07
问题 I have a dataset that looks a little like this: ID Name Address Zip Cost 1 Bob the Builder 123 Main St 12345 1 Bob the Builder $99,999.99 2 Bob the Builder 123 Sub St 54321 $74,483.01 3 Nigerian Prince Area 51 33333 $999,999.99 3 Pinhead Larry Las Vegas 31333 $11.00 4 Fox Mulder Area 51 $0.99 where missing data is okay, unless it's obvious that they can be merged. What I mean by that is instead of the dataset above, I want to merge the rows where both the ID and Name are the same, and the

Remove duplicates where values are swapped across 2 columns in R [duplicate]

谁都会走 提交于 2020-01-22 03:27:10
问题 This question already has answers here : pair-wise duplicate removal from dataframe [duplicate] (4 answers) Closed 3 years ago . I have a simple dataframe like this: | id1 | id2 | location | comment | |-----|-----|------------|-----------| | 1 | 2 | Alaska | cold | | 2 | 1 | Alaska | freezing! | | 3 | 4 | California | nice | | 4 | 5 | Kansas | boring | | 9 | 10 | Alaska | cold | The first two rows are duplicates because id1 and id2 both went to Alaska. It doesn't matter that their comment are

Determining duplicates in a datatable

我是研究僧i 提交于 2020-01-22 00:39:06
问题 I have a data table I've loaded from a CSV file. I need to determine which rows are duplicates based on two columns ( product_id and owner_org_id ) in the datatable. Once I've determined that, I can use that information to build my result, which is a datatable containing only the rows that are not unique, and a data table containing only the rows that are unique. I've looked at other examples on here and the code I've come up with so far does compile and execute, but it seems to think every

Duplicated rows: select rows based on criteria and store duplicated values

∥☆過路亽.° 提交于 2020-01-21 21:39:17
问题 I am working on a raw dataset that looks something like this: df <- data.frame("ID" = c("Alpha", "Alpha", "Alpha", "Alpha", "Beta","Beta", "Beta","Beta" ), "treatment"= LETTERS[seq(from = 1, to = 8)], "Year" = c(1970, 1970, 1980, 1990, 1970, 1980, 1980,1990), "Val" = c(0,0,0,1,0,1,0,1), "Val2" = c(0,2.34,1.3,0,0,2.34,3.2,1.3)) The data is a bit dirty as I have multiple observations for each ID and Year identifier - e.g. I have 2 different rows for Alpha in 1970. The same holds for Beta in

python ordered dict with duplicates keys

扶醉桌前 提交于 2020-01-21 14:39:14
问题 I'm trying to write some python functions to generate a batch of input files, in which there is, for instance, this block: ***behavior **energy_phase_1 ef_v 10 **energy_phase_2 ef_v 7. So far i was using collections.OrderedDict, because order matters in this kind of input file). For instance,if there are two simulations in my batch: inp_dict['***behavior'] = [ '', ''] inp_dict['**energy_phase_1'] = [ '', ''] inp_dict['**ef_v'] = [ '10', '20'] inp_dict['**energy_phase_2'] = [ '', ''] inp_dict[

python ordered dict with duplicates keys

ε祈祈猫儿з 提交于 2020-01-21 14:38:37
问题 I'm trying to write some python functions to generate a batch of input files, in which there is, for instance, this block: ***behavior **energy_phase_1 ef_v 10 **energy_phase_2 ef_v 7. So far i was using collections.OrderedDict, because order matters in this kind of input file). For instance,if there are two simulations in my batch: inp_dict['***behavior'] = [ '', ''] inp_dict['**energy_phase_1'] = [ '', ''] inp_dict['**ef_v'] = [ '10', '20'] inp_dict['**energy_phase_2'] = [ '', ''] inp_dict[

How to prevent duplicate usernames when people register? PHP/MySQL

最后都变了- 提交于 2020-01-21 04:55:10
问题 I have been making a login/register system and I am drawing close to finishing my register portion of code. The only problem I am running into is how to make it so that users cannot register with duplicated usernames. I want it to work so that my database wont accept the information, and it will tell the user about the error. Any help is appreciated. My PHP <?php include ('database_connection.php'); if (isset($_POST['formsubmitted'])) { $error = array();//Declare An Array to store any error

Python: remove duplicates from a multi-dimensional array

ⅰ亾dé卋堺 提交于 2020-01-20 05:20:34
问题 In Python numpy.unique can remove all duplicates from a 1D array, very efficiently. 1) How about to remove duplicate rows or columns in a 2D array ? 2) How about for nD arrays ? 回答1: If possible I would use pandas. In [1]: from pandas import * In [2]: import numpy as np In [3]: a = np.array([[1, 1], [2, 3], [1, 1], [5, 4], [2, 3]]) In [4]: DataFrame(a).drop_duplicates().values Out[4]: array([[1, 1], [2, 3], [5, 4]], dtype=int64) 回答2: The following is another approach which performs much